Slackbot
01/26/2023, 9:32 PMtilak chowdary
01/26/2023, 10:05 PMSergio Ferragut
01/26/2023, 11:00 PMtilak chowdary
01/27/2023, 1:03 AMREPLACE statements acquire an exclusive write lock to the target time range of the target datasource. No other ingestion or compaction operations may proceed for that time range while the task is running.would that mean compaction waits while SQL ingestion is running on a segment?. As the time range should align with the PARTITIONED BY clause, It means that we can only REPLACE one hour time range. Our one hour data would be 15mil rows and each row would be 100bytes, that is ~1.5 to 2 GB data per batch.
tilak chowdary
01/27/2023, 1:04 AMSergio Ferragut
01/27/2023, 4:30 PMtilak chowdary
01/27/2023, 5:01 PMdimenstions(_time, id, tags) metrics( duration)
{"timestamp": "2011-01-12T00:00:00.000Z", "abc", ["t1","t2","t3"], 1} #row1
{"timestamp": "2011-01-12T00:00:00.000Z", "abc", ["t3","t4","t5"], 2} #row2
{"timestamp": "2011-01-12T00:00:00.000Z", "abc", ["t5","t6","t7"], 3} #row3
{"timestamp": "2011-01-12T00:00:00.000Z", "abc", [], 4} #row4
we're expecting
_time, id, tags (union), duration(max)
{"timestamp": "2011-01-12T00:00:00.000Z", "abc", ["t1","t2","t3", "t4","t5","t6","t7"], 4}Sergio Ferragut
01/27/2023, 10:41 PM{"timestamp": "2011-01-12T00:00:00.000Z", "trip_types": ["walk","drive","fly"], "duration":6}
{"timestamp": "2011-01-12T00:00:00.000Z", "trip_types": ["walk","bus","walk"], "duration":53}
{"timestamp": "2011-01-14T00:00:00.000Z", "trip_types": ["drive","fly","drive"], "duration":60}
{"timestamp": "2011-01-14T00:00:00.000Z", "trip_types": ["jump"], "duration":0}
The SQL based ingestion query, you'll need to set "Enable Group By multi-value unnesting" to True in the query context:
REPLACE INTO "inline_data" OVERWRITE ALL
WITH "ext" AS (SELECT *
FROM TABLE(
EXTERN(
'{"type":"inline","data":"{\"timestamp\": \"2011-01-12T00:00:00.000Z\", \"trip_types\": [\"walk\",\"drive\",\"fly\"], \"duration\":6} \n{\"timestamp\": \"2011-01-12T00:00:00.000Z\", \"trip_types\": [\"walk\",\"bus\",\"walk\"], \"duration\":53} \n{\"timestamp\": \"2011-01-14T00:00:00.000Z\", \"trip_types\": [\"drive\",\"fly\",\"drive\"], \"duration\":60} \n{\"timestamp\": \"2011-01-14T00:00:00.000Z\", \"trip_types\": [\"jump\"], \"duration\":0} "}',
'{"type":"json"}',
'[{"name":"timestamp","type":"string"},{"name":"trip_types","type":"string"},{"name":"duration","type":"long"}]'
)
))
SELECT
TIME_PARSE("timestamp") AS "__time",
ARRAY_CONCAT_AGG( MV_TO_ARRAY("trip_types")) AS "trip_types",
SUM("duration") "duration"
FROM "ext"
GROUP BY 1
PARTITIONED BY DAY
The table ends up with:
__time trip_types duration
2011-01-12T00:00:00.000Z ["walk","drive","fly","walk","bus","walk"] 59
2011-01-14T00:00:00.000Z ["drive","fly","drive","jump"] 60tilak chowdary
01/27/2023, 10:54 PMSergio Ferragut
01/28/2023, 12:10 AMtilak chowdary
01/28/2023, 12:33 AMSergio Ferragut
02/02/2023, 8:39 PMtilak chowdary
02/02/2023, 10:03 PM