Skip to content

Support DuckDB style struct syntax #11214

New issue

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

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

Already on GitHub? # to your account

Merged
merged 9 commits into from
Jul 3, 2024
Merged

Conversation

jayzhan211
Copy link
Contributor

Which issue does this PR close?

Closes #9820 .

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added sql SQL Planner logical-expr Logical plan and expressions core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) labels Jul 2, 2024
@jayzhan211 jayzhan211 marked this pull request as ready for review July 2, 2024 13:58
@jayzhan211 jayzhan211 marked this pull request as draft July 2, 2024 13:58
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
@jayzhan211 jayzhan211 marked this pull request as ready for review July 3, 2024 00:42
}
}

internal_err!("Expected a simplified result, but none was found")
Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to return a not_impl_err error?
User may only use SqlToRel without a SessionState.

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks @jayzhan211 -- this is so cool!

DataFusion CLI v39.0.0
> select {'foo': 1};
+------------------------------------+
| named_struct(Utf8("foo"),Int64(1)) |
+------------------------------------+
| {foo: 1}                           |
+------------------------------------+
1 row(s) fetched.
Elapsed 0.015 seconds.

> select {'foo': {'bar': 2}};
+--------------------------------------------------------------+
| named_struct(Utf8("foo"),named_struct(Utf8("bar"),Int64(2))) |
+--------------------------------------------------------------+
| {foo: {bar: 2}}                                              |
+--------------------------------------------------------------+
1 row(s) fetched.
Elapsed 0.002 seconds.

I took the liberty of merging up from main to resolve a conflict, and since I had the PR open I also implemented @jonahgao 's suggestion and updated some comments. Hope you don't mind

THank you again

@alamb alamb changed the title Support DuckDB style stuct syntax Support DuckDB style struct syntax Jul 3, 2024

user_defined_sql_planners.push(extract_planner);
}
let user_defined_sql_planners: Vec<Arc<dyn UserDefinedSQLPlanner>> = vec![
Copy link
Contributor

Choose a reason for hiding this comment

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

I also took the opportunity while I had this PR checked out to resolve a conflict to consolidate the code in the constructor

cc @dharanad and @xinlifoobar

@jayzhan211
Copy link
Contributor Author

Great! 💯
Thanks @alamb and @jonahgao

@jayzhan211 jayzhan211 merged commit fe66daa into apache:main Jul 3, 2024
24 checks passed
@jayzhan211 jayzhan211 deleted the struct-literal branch July 3, 2024 23:29
comphead pushed a commit to comphead/arrow-datafusion that referenced this pull request Jul 8, 2024
* struct literal

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

* add nested

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

* fmt

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

* rm useless comment

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

* switch to NYI error, derive debug/clone

* improve documentation strings

* Avoid stack overflow by putting code in a new function

---------

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
* struct literal

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

* add nested

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

* fmt

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

* rm useless comment

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

* switch to NYI error, derive debug/clone

* improve documentation strings

* Avoid stack overflow by putting code in a new function

---------

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
core Core DataFusion crate logical-expr Logical plan and expressions sql SQL Planner sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support DuckDB style stuct syntax
3 participants