Uh oh!
There was an error while loading. Please reload this page.
Support for SQLContext - #999
Conversation
billylanchantin
commented
Oct 2, 2024
Hi @ceyhunkerti! Quick question before I dig into the code. You say:
Would |
Hey, thanks for the quick feedback, |
billylanchantin
commented
Oct 2, 2024
Ah I see. A function that only works on one frame certainly won't enable multi-frame joins! Thanks for clarifying the goal. I'll take a look soon. Note: we were/are hesitant about supporting Polars-specific SQL interfaces. You can read the discussion here: We went with |
ceyhunkerti
commented
Oct 2, 2024
hmm, thinking loudly 🤔 to understand backend independence.
# pseudodf1=DF.sql("select ...",backend: polars)|>computedf2=DF.some_action(df1,backend: my_new_backend)I believe the above one is not possible unless I think by backend independence we just imply the If we are worrying about the PS. When thinking of another backend, first one comes to my mind is btw, I do these for learning purposes and am happy to support if I can. We can park this one for now if you'd like, and I can focus on something else that you think might be more helpful or a higher priority. |
josevalim
commented
Oct 2, 2024
What if we allow |
josevalim
commented
Oct 2, 2024
Or this could be even better: |
billylanchantin
commented
Oct 2, 2024
@josevalim You read my mind! Perhaps even: DF.sql(%{foo: df1,bar: df2,baz: df3},"select")to prevent duplicates? Also I think behind the scenes we'd need to individually register each table with SQLContext. |
josevalim
commented
Oct 2, 2024
If we use a map, we don't have the concept of "first". |
Also mentioned something similar to it in here Back to the original issue.
DF.sql("select",%{})seems more natural to me like |
Also, this referenced issue here In the issue author mentioned in order to achieve complex result=all_pairs|>DataFrame.join(all_relationships_1,how: :left,on: [{"table_name_1","table_name"},{"column_name_1","column_name"},{"table_name_2","referenced_table_name"},{"column_name_2","referenced_column_name"}])|>DataFrame.join(all_relationships_2,how: :left,on: [{"table_name_2","table_name"},{"column_name_2","column_name"},{"table_name_1","referenced_table_name"},{"column_name_1","referenced_column_name"}])|>DataFrame.mutate(has_relationship: coalesce(has_relationship_1,has_relationship_2))So not exactly sure what At the end, this case, IMHO, justifies having a powerful |
Implements simplified SQL API proposed by Jose Valim that allows executing SQL queries across multiple DataFrames using a map. Features: - New sql/2 function accepts a map of table names to DataFrames - Backward compatible with existing sql/2 and sql/3 for single DataFrame - Uses Polars SQLContext internally for query execution - Supports JOINs, LEFT JOINs, aggregations, and other SQL operations - Comprehensive test suite with 20 tests Based on PR elixir-explorer#999 but simplified per Jose Valim's suggestion for a cleaner API.
sql_context_test.exsfile to demonstrate the usage pattern.Request for Feedback
@billylanchantin, @josevalim, @philss,
@anyone_maintaining_the_repo:). I would greatly appreciate it if you could review this and provide feedback, pointing me in the right direction for any improvements.Notes
Thank you for your time and guidance!