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

SNOW-1563484 Remove Advanced Query Pushdown Feature #572

Merged
merged 9 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,6 @@ class ColumnNameCaseSuite extends IntegrationSuiteBase {
.agg(count("*").alias("new_col"))
.count()

val result =
s"""
|SELECT ( COUNT ( 1 ) ) AS "SUBQUERY_2_COL_0" FROM ( SELECT * FROM
|( SELECT * FROM ( $table3 ) AS "SF_CONNECTOR_QUERY_ALIAS" ) AS
| "SUBQUERY_0" GROUP BY "SUBQUERY_0"."col" ) AS "SUBQUERY_1" LIMIT 1
|""".stripMargin.replaceAll("\\s", "")

assert(Utils.getLastSelect.replaceAll("\\s", "").equals(result))
}

test("Test row_number function") {
Expand All @@ -160,32 +152,6 @@ class ColumnNameCaseSuite extends IntegrationSuiteBase {
df.withColumn("rank", row_number().over(windowsSpec))
.filter("rank=1")
.collect()

// scalastyle:off println
println(Utils.getLastSelect)
// scalastyle:on println
assert(
Utils.getLastSelect
.replaceAll("\\s", "")
.equals(s"""SELECT * FROM ( SELECT ( "SUBQUERY_0"."id" ) AS "SUBQUERY_1_COL_0" ,
|( "SUBQUERY_0"."time" ) AS "SUBQUERY_1_COL_1" , ( ROW_NUMBER () OVER
|( PARTITION BY "SUBQUERY_0"."id" ORDER BY ( "SUBQUERY_0"."time" ) DESC
|) ) AS "SUBQUERY_1_COL_2" FROM ( SELECT * FROM ( $table3 ) AS
|"SF_CONNECTOR_QUERY_ALIAS" ) AS "SUBQUERY_0" ) AS "SUBQUERY_1" WHERE
|( ( "SUBQUERY_1"."SUBQUERY_1_COL_2" IS NOT NULL ) AND ( "SUBQUERY_1".
|"SUBQUERY_1_COL_2" = 1 ) )
|""".stripMargin.replaceAll("\\s", "")) ||
Utils.getLastSelect
.replaceAll("\\s", "")
.equals(s"""SELECT * FROM ( SELECT ( "SUBQUERY_0"."id" ) AS "SUBQUERY_1_COL_0" ,
| ( "SUBQUERY_0"."time" ) AS "SUBQUERY_1_COL_1" , ( ROW_NUMBER () OVER
| ( PARTITION BY "SUBQUERY_0"."id" ORDER BY ( "SUBQUERY_0"."time" ) DESC
| ) ) AS "SUBQUERY_1_COL_2" FROM ( SELECT * FROM ( $table3 ) AS
| "SF_CONNECTOR_QUERY_ALIAS" ) AS "SUBQUERY_0" ) AS "SUBQUERY_1" WHERE
| ( "SUBQUERY_1"."SUBQUERY_1_COL_2" = 1 )
|""".stripMargin.replaceAll("\\s", ""))
)

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -191,28 +191,6 @@ class DataTypesIntegrationSuite extends IntegrationSuiteBase {
.agg(count("*").alias("abc"))
.collect()

assert(
Utils.getLastSelect.equals(
s"""SELECT ( "SUBQUERY_2"."SUBQUERY_2_COL_0" ) AS "SUBQUERY_3_COL_0" , ( COUNT ( 1 ) )
| AS "SUBQUERY_3_COL_1" FROM ( SELECT ( "SUBQUERY_1"."id" ) AS "SUBQUERY_2_COL_0" FROM
| ( SELECT * FROM ( SELECT * FROM ( $test_table ) AS "SF_CONNECTOR_QUERY_ALIAS" )
| AS "SUBQUERY_0" WHERE ( ( ( "SUBQUERY_0"."time" IS NOT NULL ) AND ( "SUBQUERY_0"."time" >=
| DATEADD(day, 18140 , TO_DATE('1970-01-01')) ) ) AND ( "SUBQUERY_0"."time" <=
| DATEADD(day, 18201 , TO_DATE('1970-01-01')) ) ) ) AS "SUBQUERY_1" ) AS "SUBQUERY_2"
| GROUP BY "SUBQUERY_2"."SUBQUERY_2_COL_0"""".stripMargin.filter(_ >= ' ')
) ||
Utils.getLastSelect.equals(
s"""SELECT ( "SUBQUERY_2"."SUBQUERY_2_COL_0" ) AS "SUBQUERY_3_COL_0" , ( COUNT ( 1 ) )
| AS "SUBQUERY_3_COL_1" FROM ( SELECT ( "SUBQUERY_1"."id" ) AS "SUBQUERY_2_COL_0" FROM
| ( SELECT * FROM ( SELECT * FROM ( $test_table ) AS
| "SF_CONNECTOR_QUERY_ALIAS" ) AS "SUBQUERY_0" WHERE
| ( ( "SUBQUERY_0"."time" IS NOT NULL ) AND ( ( "SUBQUERY_0"."time" >= DATEADD(day,
| 18140 , TO_DATE('1970-01-01')) ) AND ( "SUBQUERY_0"."time" <= DATEADD(day, 18201 ,
| TO_DATE('1970-01-01')) ) ) ) ) AS "SUBQUERY_1" ) AS "SUBQUERY_2"
| GROUP BY "SUBQUERY_2"."SUBQUERY_2_COL_0"""".stripMargin.filter(_ >= ' ')
)
)

assert(result.length == 1)
assert(result(0)(1) == 2)

Expand All @@ -229,31 +207,6 @@ class DataTypesIntegrationSuite extends IntegrationSuiteBase {
.agg(count("*").alias("abc"))
.show()

assert(
Utils.getLastSelect.equals(
s"""SELECT * FROM ( SELECT ( CAST ( "SUBQUERY_2"."SUBQUERY_2_COL_0" AS VARCHAR ) )
| AS "SUBQUERY_3_COL_0" , ( CAST ( COUNT ( 1 ) AS VARCHAR ) ) AS "SUBQUERY_3_COL_1"
| FROM ( SELECT ( "SUBQUERY_1"."id" ) AS "SUBQUERY_2_COL_0" FROM ( SELECT * FROM
| ( SELECT * FROM ( $test_table ) AS "SF_CONNECTOR_QUERY_ALIAS" ) AS "SUBQUERY_0"
| WHERE ( ( ( "SUBQUERY_0"."time" IS NOT NULL ) AND ( "SUBQUERY_0"."time" <=
| DATEADD(day, 18140 , TO_DATE('1970-01-01')) ) ) AND ( "SUBQUERY_0"."time" >=
| DATEADD(day, 18201 , TO_DATE('1970-01-01')) ) ) ) AS "SUBQUERY_1" ) AS "SUBQUERY_2"
| GROUP BY "SUBQUERY_2"."SUBQUERY_2_COL_0" ) AS "SUBQUERY_3" LIMIT 21
|""".stripMargin.filter(_ >= ' ')) ||
Utils.getLastSelect.equals(
s"""SELECT * FROM ( SELECT ( CAST ( "SUBQUERY_2"."SUBQUERY_2_COL_0" AS VARCHAR ) )
| AS "SUBQUERY_3_COL_0" , ( CAST ( COUNT ( 1 ) AS VARCHAR ) ) AS "SUBQUERY_3_COL_1"
| FROM ( SELECT ( "SUBQUERY_1"."id" ) AS "SUBQUERY_2_COL_0" FROM ( SELECT * FROM
| ( SELECT * FROM ( $test_table ) AS "SF_CONNECTOR_QUERY_ALIAS" )
| AS "SUBQUERY_0" WHERE ( ( "SUBQUERY_0"."time" IS NOT NULL ) AND
| ( ( "SUBQUERY_0"."time" <= DATEADD(day, 18140 , TO_DATE('1970-01-01')) ) AND
| ( "SUBQUERY_0"."time" >= DATEADD(day, 18201 , TO_DATE('1970-01-01')) ) ) ) )
| AS "SUBQUERY_1" ) AS "SUBQUERY_2" GROUP BY "SUBQUERY_2"."SUBQUERY_2_COL_0" )
| AS "SUBQUERY_3" LIMIT 21
|""".stripMargin.filter(_ >= ' ')
)
)

jdbcUpdate(s"drop table $test_table")
}

Expand Down Expand Up @@ -287,27 +240,6 @@ class DataTypesIntegrationSuite extends IntegrationSuiteBase {
.agg(count("*").alias("abc"))
.collect()

assert(
Utils.getLastSelect.equals(
s"""SELECT ( "SUBQUERY_2"."SUBQUERY_2_COL_0" ) AS "SUBQUERY_3_COL_0" , ( COUNT ( 1 ) )
| AS "SUBQUERY_3_COL_1" FROM ( SELECT ( "SUBQUERY_1"."id" ) AS "SUBQUERY_2_COL_0" FROM
| ( SELECT * FROM ( SELECT * FROM ( $test_table ) AS "SF_CONNECTOR_QUERY_ALIAS" ) AS
| "SUBQUERY_0" WHERE ( ( ( "SUBQUERY_0"."time" IS NOT NULL ) AND ( "SUBQUERY_0"."time"
| >= to_timestamp_ntz( 1564358400000000 , 6) ) ) AND ( "SUBQUERY_0"."time" <=
| to_timestamp_ntz( 1567036800000000 , 6) ) ) ) AS "SUBQUERY_1" ) AS "SUBQUERY_2"
| GROUP BY "SUBQUERY_2"."SUBQUERY_2_COL_0"""".stripMargin.filter(_ >= ' ')
) ||
Utils.getLastSelect.equals(
s"""SELECT ( "SUBQUERY_2"."SUBQUERY_2_COL_0" ) AS "SUBQUERY_3_COL_0" , ( COUNT ( 1 ) )
| AS "SUBQUERY_3_COL_1" FROM ( SELECT ( "SUBQUERY_1"."id" ) AS "SUBQUERY_2_COL_0" FROM
| ( SELECT * FROM ( SELECT * FROM ( $test_table ) AS "SF_CONNECTOR_QUERY_ALIAS" ) AS
| "SUBQUERY_0" WHERE ( ( "SUBQUERY_0"."time" IS NOT NULL ) AND ( ( "SUBQUERY_0"."time"
| >= to_timestamp_ntz( 1564358400000000 , 6) ) AND ( "SUBQUERY_0"."time" <=
| to_timestamp_ntz( 1567036800000000 , 6) ) ) ) ) AS "SUBQUERY_1" ) AS "SUBQUERY_2"
| GROUP BY "SUBQUERY_2"."SUBQUERY_2_COL_0"""".stripMargin.filter(_ >= ' ')
)
)

assert(result.length == 1)
assert(result(0)(1) == 2)

Expand All @@ -328,31 +260,6 @@ class DataTypesIntegrationSuite extends IntegrationSuiteBase {
.agg(count("*").alias("abc"))
.show()

assert(
Utils.getLastSelect.equals(
s"""SELECT * FROM ( SELECT ( CAST ( "SUBQUERY_2"."SUBQUERY_2_COL_0" AS VARCHAR ) )
| AS "SUBQUERY_3_COL_0" , ( CAST ( COUNT ( 1 ) AS VARCHAR ) ) AS "SUBQUERY_3_COL_1"
| FROM ( SELECT ( "SUBQUERY_1"."id" ) AS "SUBQUERY_2_COL_0" FROM ( SELECT * FROM
| ( SELECT * FROM ( $test_table ) AS "SF_CONNECTOR_QUERY_ALIAS" ) AS "SUBQUERY_0"
| WHERE ( ( ( "SUBQUERY_0"."time" IS NOT NULL ) AND ( "SUBQUERY_0"."time" <=
| to_timestamp_ntz( 1564358400000000 , 6) ) ) AND ( "SUBQUERY_0"."time" >=
| to_timestamp_ntz( 1567036800000000 , 6) ) ) ) AS "SUBQUERY_1" ) AS "SUBQUERY_2"
| GROUP BY "SUBQUERY_2"."SUBQUERY_2_COL_0" ) AS "SUBQUERY_3" LIMIT 21
|""".stripMargin.filter(_ >= ' ')) ||
Utils.getLastSelect.equals(
s"""SELECT * FROM ( SELECT ( CAST ( "SUBQUERY_2"."SUBQUERY_2_COL_0" AS VARCHAR ) )
| AS "SUBQUERY_3_COL_0" , ( CAST ( COUNT ( 1 ) AS VARCHAR ) ) AS "SUBQUERY_3_COL_1"
| FROM ( SELECT ( "SUBQUERY_1"."id" ) AS "SUBQUERY_2_COL_0" FROM ( SELECT * FROM
| ( SELECT * FROM ( $test_table ) AS "SF_CONNECTOR_QUERY_ALIAS" ) AS "SUBQUERY_0"
| WHERE ( ( "SUBQUERY_0"."time" IS NOT NULL ) AND ( ( "SUBQUERY_0"."time" <=
| to_timestamp_ntz( 1564358400000000 , 6) ) AND ( "SUBQUERY_0"."time" >=
| to_timestamp_ntz( 1567036800000000 , 6) ) ) ) ) AS "SUBQUERY_1" ) AS "SUBQUERY_2"
| GROUP BY "SUBQUERY_2"."SUBQUERY_2_COL_0" ) AS "SUBQUERY_3" LIMIT 21
|""".stripMargin.filter(_ >= ' '))
)

jdbcUpdate(s"drop table $test_table")

}

}
Loading
Loading