Type.Type (etl_core v0.1.54)

Module for working with data types

Link to this section 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

Link to this section Functions

Converts a data to its equivalent of a defined type

parameters

Parameters:

- x. Data to convert.

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

return

Return:

- value | nil | Exception

examples

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

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

Parameter:

- x: t(). Value.

return

Return:

- String
Link to this function

convert_from_bigquery(x)

Convert bigquery text to understandable format

parameter

Parameter:

- x: t(). Value.

return

Return:

- String