Type.Type (etl_core v0.1.55)

Module for working with data types

Summary

Functions

Converts a data to its equivalent of a defined type

Converts the data into a format understandable by BigQuery

Convert bigquery text to understandable format

Functions

Converts a data to its equivalent of a defined type

Parameters:

- x. Data to convert.

- to: Data type that `x` will be converted to.

Return:

- value | nil | Exception

Examples:

iex> Type.convert(2, :float)
2.0

iex> Type.convert("2", :integer)
2

iex>Type.convert("14", :integer)
14Type.convert("chain", :map)

iex> Type.convert("chain", :string)
"chain"

iex> Type.convert("chain", :map)
(throw) "NotImplementedError => from `binary` to `map`"

iex> Type.convert(1668036600542, :string_datetime)
"2022-11-09T23:30:00.542Z"

Special considerations:

- Elixir built-in data types to work with: binary, nil, integer, float, atom, list, map, boolean.

- Elixir's non-built-in data types to work with: DateTime

- Elixir non-existent data types, but need to create its name:

    - string: Binary equivalent.

    - string_datetime: Equivalent to converting from an integer to a binary, in DateTime format.
Link to this function

convert_for_bigquery(x)

Converts the data into a format understandable by BigQuery

Parameter:

- x: t(). Value.

Return:

- String
Link to this function

convert_from_bigquery(x)

Convert bigquery text to understandable format

Parameter:

- x: t(). Value.

Return:

- String