Solved

SQL Query for timeseries

  • 31 January 2024
  • 2 replies
  • 52 views

Userlevel 1
Badge

I have 3 Tables

  1. time series
  2. timeseries2asset
  3. asset

for asset, i am using this sql query

 SELECT
-- CAST(a.`tag` AS STRING) AS name,
-- CAST(a.`description` AS STRING) AS description,
-- CAST(a.`sourceDb` AS STRING) AS source,
CAST(a.`externalId` AS STRING) AS externalId,
-- MAP(
-- 'key', CAST(a.`key` AS STRING),
-- 'updatedDate', CAST(a.`updatedDate` AS STRING),
-- 'createdDate', CAST(a.`createdDate` AS STRING),
-- 'isCriticalLine', CAST(a.`isCriticalLine` AS STRING),
-- 'areaId', CAST(a.`areaId` AS STRING),
-- 'isActive', CAST(a.`isActive` AS STRING)
-- ) AS metadata,
-- CAST(NULL AS LONG) AS parentId,
CAST(a.`parentExternalId` AS STRING) AS parentExternalId
-- 7470047 AS dataSetId,
-- ARRAY(NULL) AS labels
FROM `CognitePOC`.`assets` a

for timeseries i am using this query

 select
   cast(`external_id` as STRING) as externalId,
   cast(`name` as STRING) as name,
   cast(`is_string` as BOOLEAN) as isString,
   cast(`unit` as STRING) as unit,
   cast(`is_step` as BOOLEAN) as isStep,
   cast(`description` as STRING) as description,
   7470047 as dataSetId
 from
   `Cognite`.`timeseries`


I have 3rd csv as timeseries2asset i want to update time series and i have to connect them to the asset how to do that

timeseries2asset columns - Key, externalId, sourceExternalId, targetExternalId

icon

Best answer by Sofie Haug 31 January 2024, 12:23

View original

2 replies

Userlevel 1
Badge

timeseries2asset columns - key, timeseries, asset

these are the columns in previous question the column names are wrong

Userlevel 3
Badge +6

I suggest you take a look at the CDF Fundamentals learning path, specifically the Working with CDF: Contextualize https://learn.cognite.com/path/cognite-data-fusion-fundamentals/working-with-cdf-contextualize

In the events lesson you can see an example of how events can be linked to assets, the same goes for time series. But by using CDF Transformation you need to have a column that matches something in the assets information. So that you have something to link them by. 

If not, also in the course linked above, you can find an example on how to use the Entity matcher tool to match time series to assets. 

Reply