Is there a way to use column names in a string concatenation?
Hi! Does using a constant for string concatenation satisfy your use case?
I’d like to be able to pull the column name down as a string to concatenate with row values. Essentially trying to fill in a matrix that is required to populate SeriesIDs for Time Series syncs that back time series properties in the ontology.
Let’s say I have sensors for temperature and humidity across several locations. I need to fill in the below table to back my “Location” object with several time series syncs:
location | temperature | humidity |
---|---|---|
A | temperature_a | humidity_a |
B | temperature_b | humidity_b |
C | temperature_c | humidity_c |
Where the values in the temperature and humidity columns are the SeriesIDs that point to the respective time series sync.
Sorry, I am having some trouble visualizing - is temperature_a
literally the exact string “temperature_a” or is it a temperature that has “a” appended?
Hi, this is my question and @mitchp is helping me as a member of the Palantir for Builders team. It would actually be the literal string “temperature” and “a” would be the location of that row. For example:
location | temperature | humidity |
---|---|---|
London | temperature_london | humidity_london |
Munich | temperature_munich | humidity_munich |
Berlin | temperature_berlin | humidity_berlin |
As @mitchp mentioned, the idea here is to have an object (in this case it would be some city object) whose attributes hold the Series IDs for their corresponding Time Series syncs. So, a series would look something like:
series_id | timestamp | value |
---|---|---|
temperature_london | 1000001 | 1 |
temperature_london | 1000002 | 2 |
temperature_london | 1000003 | 3 |
Ah gotcha, then the string concatenate operation seems highly suitable! You can pass in the literal string “temperature_” as the first value and then the column location
as the second argument, which will give you the output you described. Similar for “humidity”.
We would really benefit from a programmatic way to pull the column names down into the string concatenation though. At 2 columns, manual mapping is fine, but we will be dealing with 100s of columns that are each mapping to sensor readings.
You can write a UDF to transform your columns!