ETLMCPData Conveyance Works
Log in Start free
Docs

Which delivered columns are numeric and which are text

Which columns etlmcp delivers as numbers and which as text, why a derive result arrives as text, and where a value that is not a number goes.

etlmcp decides which columns may hold numbers from where their values come from, not from a guess at the data. The common metric columns, the extras a connector lists in its catalogue, and the roas a group rule works out are numbers. Constants, the results of derive rules, names, IDs and anything else are text. The data can only turn a would-be number column into text, never the other way round. In PostgreSQL, a number column is created as double precision, date as date, and every other column as text.

The columns that are numbers

These columns are always numbers, whatever rules the pipeline has:

  • impressions, clicks, cost, conversions and conversion_value
  • the ratios ctr, cpc, cpm and cpa

A platform's extras arrive as extra.<name> columns. The ones the connector catalogues are numbers; an extra the catalogue does not name is text. A connector's page lists its catalogued extras, for example the GA4 connector. A connector that catalogues none, such as Meta, delivers all its extras as text.

How your rules change a column's type

etlmcp follows your rule list in order, so a column's type after the last rule is what your table gets:

  • rename: the new name keeps the old column's type. Renaming cost to spend gives you a numeric spend.
  • constant: the column you set is text, even when the value you set looks like a number.
  • derive: the column named in as is text (see the derive rule). A derived roas of conversion_value / cost reaches PostgreSQL as text such as 2.5.
  • group: after a group rule, the common metrics, roas and every extra. column it keeps are numbers, because the group combines them or works them out. The columns you group by, other than date, are text.

A constant or derive that writes over a common metric, such as cost, does not change its type, and neither does grouping by one: the common metrics stay numbers.

For ROAS as a number column, use a group rule: for each group with a cost other than zero, it computes roas as conversion value divided by cost. You can cast a derived value when you read it, for example CAST(roas AS double precision).

When a numeric column still arrives as text

A column that should hold numbers, other than a common metric, only gets a number type if every value in that delivery is a number or empty. One text value in the column, and it gets text instead. This test applies when etlmcp creates your table and when it adds a new extra column to a table it made earlier.

A number too large for a double to hold exactly as a whole number makes such a column text too. PostgreSQL's double precision is an inexact type: its own documentation gives it a precision of at least 15 digits, so a very large whole number such as a long ID could lose its last digits. Rather than change the digits, etlmcp keeps such a column as text.

A value that is not a number, in a column that takes numbers

A column's type is fixed once your table has it. A later run cannot turn a number column into text, even if your rules now produce text in it. When etlmcp reads your existing table, a column of type double precision, real, numeric, integer or bigint counts as a number column, and every other column as text. So when a value reaches an existing number column of your table:

  • text that spells a number, such as "12.5", is written as that number;
  • anything else is written as empty, and the original text is parked in a text column named <column>_text beside it. A text value in extra.leads goes to extra.leads_text.

etlmcp adds the <column>_text column itself, or uses one your table already has as text. It leaves the text out instead when the rows already carry a column of that name, when the table has that column with another type, when the name is too long for PostgreSQL, or when the database login may not add columns to the table. The common metric columns are never parked.

To find parked values, query the _text column for rows where it is not empty. Extra columns keep their dots in PostgreSQL, so quote them: SELECT date, "extra.leads_text" FROM your_table WHERE "extra.leads_text" IS NOT NULL.

CSV files

CSV files carry no column types: every cell is text in the file, and the spreadsheet or tool that opens it decides.

Related

Sources

  1. 8.1. Numeric Types — www.postgresql.org, checked