Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support JSON as input (and output?) format #22

Open
mechatroner opened this issue Oct 24, 2020 · 4 comments
Open

Support JSON as input (and output?) format #22

mechatroner opened this issue Oct 24, 2020 · 4 comments

Comments

@mechatroner
Copy link
Owner

One of the main problems is supporting JOIN, when we have a query like select * JOIN other_file.json on a['key'] = b['key']['subkey'], what should the output records be? One option would be to output [a, b] which would be valid json too. We would also have to create an alternative join map generation that would have to be eval-based, currently we convert join variables to indexes to generate the join map, but with JSON it is not possible.

@mechatroner
Copy link
Owner Author

Actually, if we allow JSON as output, the exact output record structure shouldn't be viewed as a huge decision point, since with JSON output users can easily create arbitrary output structures, example:
SELECT json.dumps([a, b, {'foo': a['bar'], 'foobar': {'b': b}}]) join other_file.json on a['key'] == b['key']

Much bigger question is what should be the output records structure in case of json input and csv output (i.e. query + format conversion)

@JoeCodeswell
Copy link

Hi @mechatroner,

How hard is just doing json.dumps for a very simple object? Then just say that's the limitation for now?

Thanks for the good work.

Love and peace,
Joe

@mechatroner
Copy link
Owner Author

Hi @JoeCodeswell, Thank you for the feedback!
Yeah, json.dumps will work - I just verified it, but you would need to add import json in ~/.rbql_init_source.py file. Or you can also use JSON.stringify in JS version out of the box. It is also better to set the output format as tsv instead of csv to avoid double quoting.
So output JSON is already supported to some extent.

@JoeCodeswell
Copy link

JoeCodeswell commented Feb 14, 2024 via email

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

No branches or pull requests

2 participants