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

Integration tests with require_partition_filter = true for DPO time partitioned tables #1322

Merged
merged 4 commits into from
Dec 6, 2024
Merged
Changes from 1 commit
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 @@ -1591,6 +1591,11 @@ protected Dataset<Row> writeAndLoadDatasetOverwriteDynamicPartition(Dataset<Row>
.option("temporaryGcsBucket", TestConstants.TEMPORARY_GCS_BUCKET)
.save();

IntegrationTestUtils.runQuery(
String.format(
"ALTER TABLE %s.%s SET OPTIONS (require_partition_filter = false)",
testDataset, testTable));

return spark
.read()
.format("bigquery")
Expand All @@ -1607,9 +1612,9 @@ public void testOverwriteDynamicPartition_partitionTimestampByHour() {
IntegrationTestUtils.runQuery(
String.format(
"CREATE TABLE `%s.%s` (%s INTEGER, %s TIMESTAMP) "
+ "PARTITION BY timestamp_trunc(order_date_time, HOUR) "
+ "PARTITION BY timestamp_trunc(order_date_time, HOUR) OPTIONS (require_partition_filter = true)"
+ "AS SELECT * FROM UNNEST([(1, TIMESTAMP '2023-09-28 1:00:00 UTC'), "
+ "(2, TIMESTAMP '2023-09-28 10:00:00 UTC'), (3, TIMESTAMP '2023-09-28 10:30:00 UTC')])",
+ "(2, TIMESTAMP '2023-09-28 10:00:00 UTC'), (3, TIMESTAMP '2023-09-28 10:30:00 UTC')]) ",
testDataset, testTable, orderId, orderDateTime));

Dataset<Row> df =
Expand Down Expand Up @@ -1651,7 +1656,7 @@ public void testOverwriteDynamicPartition_partitionTimestampByDay() {
IntegrationTestUtils.runQuery(
String.format(
"CREATE TABLE `%s.%s` (%s INTEGER, %s TIMESTAMP) "
+ "PARTITION BY DATE(order_date_time) "
+ "PARTITION BY DATE(order_date_time) OPTIONS (require_partition_filter = true)"
+ "AS SELECT * FROM UNNEST([(1, TIMESTAMP '2023-09-28 1:00:00 UTC'), "
+ "(2, TIMESTAMP '2023-09-29 10:00:00 UTC'), (3, TIMESTAMP '2023-09-29 17:00:00 UTC')])",
testDataset, testTable, orderId, orderDateTime));
Expand Down Expand Up @@ -1695,7 +1700,7 @@ public void testOverwriteDynamicPartition_partitionTimestampByMonth() {
IntegrationTestUtils.runQuery(
String.format(
"CREATE TABLE `%s.%s` (%s INTEGER, %s TIMESTAMP) "
+ "PARTITION BY timestamp_trunc(order_date_time, MONTH) "
+ "PARTITION BY timestamp_trunc(order_date_time, MONTH) OPTIONS (require_partition_filter = true)"
+ "AS SELECT * FROM UNNEST([(1, TIMESTAMP '2023-09-28 1:00:00 UTC'), "
+ "(2, TIMESTAMP '2023-10-20 10:00:00 UTC'), (3, TIMESTAMP '2023-10-25 12:00:00 UTC')])",
testDataset, testTable, orderId, orderDateTime));
Expand Down Expand Up @@ -1739,7 +1744,7 @@ public void testOverwriteDynamicPartition_partitionTimestampByYear() {
IntegrationTestUtils.runQuery(
String.format(
"CREATE TABLE `%s.%s` (%s INTEGER, %s TIMESTAMP) "
+ "PARTITION BY timestamp_trunc(order_date_time, YEAR) "
+ "PARTITION BY timestamp_trunc(order_date_time, YEAR) OPTIONS (require_partition_filter = true)"
+ "AS SELECT * FROM UNNEST([(1, TIMESTAMP '2022-09-28 1:00:00 UTC'), "
+ "(2, TIMESTAMP '2023-10-20 10:00:00 UTC'), (2, TIMESTAMP '2023-10-25 12:00:00 UTC')])",
testDataset, testTable, orderId, orderDateTime));
Expand Down Expand Up @@ -1783,7 +1788,7 @@ public void testOverwriteDynamicPartition_partitionDateByDay() {
IntegrationTestUtils.runQuery(
String.format(
"CREATE TABLE `%s.%s` (%s INTEGER, %s DATE) "
+ "PARTITION BY order_date "
+ "PARTITION BY order_date OPTIONS (require_partition_filter = true)"
+ "AS SELECT * FROM UNNEST([(1, DATE('2023-09-28')), (2, DATE('2023-09-29'))])",
testDataset, testTable, orderId, orderDate));

Expand Down Expand Up @@ -1823,7 +1828,7 @@ public void testOverwriteDynamicPartition_partitionDateByMonth() {
IntegrationTestUtils.runQuery(
String.format(
"CREATE TABLE `%s.%s` (%s INTEGER, %s DATE) "
+ "PARTITION BY DATE_TRUNC(order_date, MONTH) "
+ "PARTITION BY DATE_TRUNC(order_date, MONTH) OPTIONS (require_partition_filter = true)"
+ "AS SELECT * FROM UNNEST([(1, DATE('2023-09-28')), "
+ "(2, DATE('2023-10-29')), (2, DATE('2023-10-28'))])",
testDataset, testTable, orderId, orderDate));
Expand Down Expand Up @@ -1864,7 +1869,7 @@ public void testOverwriteDynamicPartition_partitionDateByYear() {
IntegrationTestUtils.runQuery(
String.format(
"CREATE TABLE `%s.%s` (%s INTEGER, %s DATE) "
+ "PARTITION BY DATE_TRUNC(order_date, YEAR) "
+ "PARTITION BY DATE_TRUNC(order_date, YEAR) OPTIONS (require_partition_filter = true)"
+ "AS SELECT * FROM UNNEST([(1, DATE('2022-09-28')), "
+ "(2, DATE('2023-10-29')), (2, DATE('2023-11-28'))])",
testDataset, testTable, orderId, orderDate));
Expand Down Expand Up @@ -1905,7 +1910,7 @@ public void testOverwriteDynamicPartition_partitionDateTimeByHour() {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
IntegrationTestUtils.runQuery(
String.format(
"CREATE TABLE `%s.%s` (%s INTEGER, %s DATETIME) "
"CREATE TABLE `%s.%s` (%s INTEGER, %s DATETIME) OPTIONS (require_partition_filter = true)"
+ "PARTITION BY timestamp_trunc(order_date_time, HOUR) "
+ "AS SELECT * FROM UNNEST([(1, DATETIME '2023-09-28 1:00:00'), "
+ "(2, DATETIME '2023-09-28 10:00:00'), (3, DATETIME '2023-09-28 10:30:00')])",
Expand Down Expand Up @@ -1948,7 +1953,7 @@ public void testOverwriteDynamicPartition_partitionDateTimeByDay() {
IntegrationTestUtils.runQuery(
String.format(
"CREATE TABLE `%s.%s` (%s INTEGER, %s DATETIME) "
+ "PARTITION BY timestamp_trunc(order_date_time, DAY) "
+ "PARTITION BY timestamp_trunc(order_date_time, DAY) OPTIONS (require_partition_filter = true)"
+ "AS SELECT * FROM UNNEST([(1, DATETIME '2023-09-28 1:00:00'), "
+ "(2, DATETIME '2023-09-29 10:00:00'), (3, DATETIME '2023-09-29 17:30:00')])",
testDataset, testTable, orderId, orderDateTime));
Expand Down Expand Up @@ -1990,7 +1995,7 @@ public void testOverwriteDynamicPartition_partitionDateTimeByMonth() {
IntegrationTestUtils.runQuery(
String.format(
"CREATE TABLE `%s.%s` (%s INTEGER, %s DATETIME) "
+ "PARTITION BY timestamp_trunc(order_date_time, MONTH) "
+ "PARTITION BY timestamp_trunc(order_date_time, MONTH) OPTIONS (require_partition_filter = true)"
+ "AS SELECT * FROM UNNEST([(1, DATETIME '2023-09-28 1:00:00'), "
+ "(2, DATETIME '2023-10-29 10:00:00'), (3, DATETIME '2023-10-29 17:30:00')])",
testDataset, testTable, orderId, orderDateTime));
Expand Down Expand Up @@ -2032,7 +2037,7 @@ public void testOverwriteDynamicPartition_partitionDateTimeByYear() {
IntegrationTestUtils.runQuery(
String.format(
"CREATE TABLE `%s.%s` (%s INTEGER, %s DATETIME) "
+ "PARTITION BY timestamp_trunc(order_date_time, YEAR) "
+ "PARTITION BY timestamp_trunc(order_date_time, YEAR) OPTIONS (require_partition_filter = true)"
+ "AS SELECT * FROM UNNEST([(1, DATETIME '2022-09-28 1:00:00'), "
+ "(2, DATETIME '2023-10-29 10:00:00'), (3, DATETIME '2023-11-29 17:30:00')])",
testDataset, testTable, orderId, orderDateTime));
Expand Down Expand Up @@ -2111,7 +2116,7 @@ public void testOverwriteDynamicPartition_rangePartitioned() {
IntegrationTestUtils.runQuery(
String.format(
"CREATE TABLE `%s.%s` (%s INTEGER, %s INTEGER) "
+ "PARTITION BY RANGE_BUCKET(order_id, GENERATE_ARRAY(1, 100, 10)) "
+ "PARTITION BY RANGE_BUCKET(order_id, GENERATE_ARRAY(1, 100, 10))"
+ "AS SELECT * FROM UNNEST([(1, 1000), "
+ "(8, 1005), ( 21, 1010), (83, 1020)])",
testDataset, testTable, orderId, orderCount));
Expand Down
Loading