Skip to content

Conversation

@kyle-cheung
Copy link
Contributor

Comment on lines +7262 to +7269
# https://docs.snowflake.com/en/sql-reference/functions/object_keys
class ObjectKeys(Func):
pass


# https://duckdb.org/docs/extensions/json#json-extraction-functions
class JsonKeys(Func):
_sql_names = ["JSON_KEYS"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should maintain only one representation for this AST node - JSONKeys(Func) is sufficient.

When adding a new function in SQLGlot, we search across all dialects (using their official documentation and manual testing) to determine if the function is supported elsewhere. This allows us to come up with the most generic AST node that supports all variations.

For example:

  • Snowflake: OBJECT_KEYS(object) - single argument
  • DuckDB: json_keys(json [, path]) - accepts an optional path argument (can be a single value or list)

With the current addition we only support a single argument, this will fail in future uses.

So, let's make a search among the dialects and check all the vacations, and make the representation generic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants