LucaCappelletti94 commented on code in PR #2425:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2425#discussion_r4099053123
##########
tests/sqlparser_databricks.rs:
##########
@@ -757,3 +757,62 @@ fn parse_databricks_query_entry_points() {
databricks()
.verified_stmt("CREATE VIEW filtered AS FROM main.raw.source |> WHERE
id > 0 |> SELECT id");
}
+
+#[test]
+fn parse_create_table_using() {
+ match databricks().verified_stmt("CREATE TABLE t (id BIGINT) USING DELTA")
{
+ Statement::CreateTable(CreateTable { hive_formats, .. }) => {
+ assert_eq!(
+ hive_formats.unwrap().storage,
+ Some(HiveIOFormat::Using {
+ format: Ident::new("DELTA")
+ })
+ );
+ }
+ s => panic!("Unexpected statement: {s:?}"),
+ }
+
+ databricks().verified_stmt("CREATE TABLE IF NOT EXISTS t (id BIGINT) USING
PARQUET");
+}
+
+#[test]
+fn parse_create_table_map_type() {
+ match databricks().verified_stmt("CREATE TABLE t (m MAP<STRING, INT>)") {
+ Statement::CreateTable(CreateTable { columns, .. }) => {
+ assert_eq!(
+ columns[0].data_type,
+ DataType::Map(
+ Box::new(DataType::String(None)),
+ Box::new(DataType::Int(None)),
+ MapBracketKind::AngleBrackets
+ )
+ );
+ }
+ s => panic!("Unexpected statement: {s:?}"),
+ }
+
+ databricks().verified_stmt("CREATE TABLE t (m MAP<STRING, ARRAY<INT>>)");
+}
+
+#[test]
+fn parse_long_type_as_bigint() {
+ match databricks()
+ .one_statement_parses_to("CREATE TABLE t (id LONG)", "CREATE TABLE t
(id BIGINT)")
+ {
+ Statement::CreateTable(CreateTable { columns, .. }) => {
+ assert_eq!(columns[0].data_type, DataType::BigInt(None));
+ }
+ s => panic!("Unexpected statement: {s:?}"),
+ }
+}
+
+#[test]
+fn parse_div_operator() {
+ databricks().one_statement_parses_to("SELECT 10 div 3", "SELECT 10 DIV 3");
+ databricks().one_statement_parses_to("SELECT c1 div c2 FROM t", "SELECT c1
DIV c2 FROM t");
+}
+
+#[test]
+fn parse_pipe_operator() {
+ databricks().verified_stmt("SELECT * FROM t |> WHERE x > 1 |> SELECT x AS
y |> ORDER BY y");
+}
Review Comment:
You should drop `parse_pipe_operator`, as Databricks already enables `|>` on
main (#2478).
```suggestion
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]