Skip to content

Add JSON access query support - #245

Open
rickpr wants to merge 1 commit into
snowflakedb:mainfrom
rickpr:master
Open

Add JSON access query support#245
rickpr wants to merge 1 commit into
snowflakedb:mainfrom
rickpr:master

Conversation

@rickpr

@rickpr rickpr commented Oct 6, 2021

Copy link
Copy Markdown

When attempting to query JSON using this syntax, I receive the following error:

sqlalchemy.exc.UnsupportedCompilationError: Compiler <snowflake.sqlalchemy.base.SnowflakeCompiler object at 0x13f6cefd0> can't render element of type <function json_getitem_op at 0x1103c4790> (Background on this error at: http://sqlalche.me/e/13/l7de)

This means my workaround is to do something like this:

session.query(table1.metadata.op(':')(sqlalchemy.text('size')))

This is not only ugly but also means that I can't prototype my operations using another database like PostgreSQL before using my code live on snowflake.

This makes JSON access possible using the regular SQLAlchemy syntax.

@u21-yizhang u21-yizhang left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I fully support this lol

@masamitsu-murase

masamitsu-murase commented May 5, 2022

Copy link
Copy Markdown

Will this pull request be merged into the main branch?
I would like to know the future plan regarding the support of JSON.

I also developed a small library, snowflake-sqlalchemy-json, to support JSON and func.flatten(...), but I'm not sure whether creating a pull request based on this library will help this project.
If someone knows the future plan about JSON, could you share it with me?

Regards,
Murase

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.

3 participants