-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed as not planned
Description
There is currently no transpilation for OBJECT_KEYS reading from Snowflake and writing DuckDB.
Reproducible Code
import sqlglot
sql = """
SELECT OBJECT_KEYS(test)
FROM test_data
"""
sqlglot.transpile(sql, "snowflake", "duckdb", pretty=True)[0]
>>
SELECT
OBJECT_KEYS(test)
FROM test_data
In Snowflake:
CREATE OR REPLACE TEMPORARY TABLE test_data AS
SELECT PARSE_JSON('{"is_active": false, "cheese_count" : 5}') AS test;
SELECT OBJECT_KEYS(test)
FROM test_data;
┌──────────────────────┐
│ object_keys(test) │
├──────────────────────┤
│ [is_active, is_true] │
└──────────────────────┘
Describe the solution you'd like
This should transpile to JSON_KEYS
SELECT json_keys(test)
FROM test_data;
Describe alternatives you've considered
n/a
Additional context
Snowflake docs https://docs.snowflake.com/en/sql-reference/functions/object_keys
DuckDB docs https://duckdb.org/docs/stable/data/json/json_functions#json-scalar-functions
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels