-
Notifications
You must be signed in to change notification settings - Fork 57
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
Fix quoted column name for Iceberg primitive type #891
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/* | ||
* Copyright (c) 2024 Snowflake Computing Inc. All rights reserved. | ||
*/ | ||
|
||
package net.snowflake.ingest.streaming.internal.it; | ||
|
||
import java.sql.ResultSet; | ||
|
@@ -13,17 +17,45 @@ | |
import net.snowflake.ingest.streaming.OpenChannelRequest; | ||
import net.snowflake.ingest.streaming.SnowflakeStreamingIngestChannel; | ||
import net.snowflake.ingest.streaming.internal.datatypes.AbstractDataTypeTest; | ||
import net.snowflake.ingest.utils.Constants; | ||
import net.snowflake.ingest.utils.SFException; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runners.Parameterized; | ||
|
||
public class ColumnNamesIT extends AbstractDataTypeTest { | ||
private static final int INGEST_VALUE = 1; | ||
|
||
@Parameterized.Parameters( | ||
name = "enableIcebergStreaming={0}, compressionAlgorithm={1}, icebergSerializationPolicy={2}") | ||
public static Object[][] parameters() { | ||
return new Object[][] { | ||
// TODO: Enable this after Iceberg testing is set up on sfctest0 GCP / Azure | ||
// {true, "ZSTD", Constants.IcebergSerializationPolicy.COMPATIBLE}, | ||
// {true, "ZSTD", Constants.IcebergSerializationPolicy.OPTIMIZED}, | ||
{false, "GZIP", null}, | ||
{false, "ZSTD", null}, | ||
sfc-gh-alhuang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
} | ||
|
||
@Parameterized.Parameter(0) | ||
public static boolean enableIcebergStreaming; | ||
|
||
@Parameterized.Parameter(1) | ||
public static String compressionAlgorithm; | ||
|
||
@Parameterized.Parameter(2) | ||
public static Constants.IcebergSerializationPolicy icebergSerializationPolicy; | ||
|
||
@Before | ||
public void before() throws Exception { | ||
super.before(); | ||
if (enableIcebergStreaming) { | ||
super.beforeIceberg(compressionAlgorithm, icebergSerializationPolicy); | ||
} else { | ||
super.compressionAlgorithm = compressionAlgorithm; | ||
super.before(); | ||
} | ||
} | ||
|
||
@Test | ||
|
@@ -93,9 +125,11 @@ public void testNullableResolution() throws Exception { | |
conn.createStatement() | ||
.execute( | ||
String.format( | ||
"create or replace table %s (AbC int, \"AbC\" int, \"abC\" int, ab\\ c int, \"Ab" | ||
+ " c\" int);", | ||
tableName)); | ||
"create or replace %s table %s (AbC int, \"AbC\" int, \"abC\" int, ab\\ c int, \"Ab" | ||
+ " c\" int) %s", | ||
enableIcebergStreaming ? "iceberg" : "", | ||
tableName, | ||
enableIcebergStreaming ? getIcebergTableConfig(tableName) : "")); | ||
SnowflakeStreamingIngestChannel channel = openChannel(tableName); | ||
String offsetToken = "token1"; | ||
channel.insertRow(new HashMap<>(), offsetToken); | ||
|
@@ -119,7 +153,12 @@ public void testNullableResolution() throws Exception { | |
public void testExtraColNames() throws Exception { | ||
String tableName = "t1"; | ||
conn.createStatement() | ||
.execute(String.format("create or replace table %s (\"create\" int);", tableName)); | ||
.execute( | ||
String.format( | ||
"create or replace %s table %s (\"create\" int) %s;", | ||
enableIcebergStreaming ? "iceberg" : "", | ||
tableName, | ||
enableIcebergStreaming ? getIcebergTableConfig(tableName) : "")); | ||
SnowflakeStreamingIngestChannel channel = | ||
openChannel(tableName, OpenChannelRequest.OnErrorOption.CONTINUE); | ||
|
||
|
@@ -152,9 +191,11 @@ public void testMissingNotNullColNames() throws Exception { | |
conn.createStatement() | ||
.execute( | ||
String.format( | ||
"create or replace table %s (\"CrEaTe\" int not null, a int not null, \"a\" int not" | ||
+ " null, \"create\" int);", | ||
tableName)); | ||
"create or replace %s table %s (\"CrEaTe\" int not null, a int not null, \"a\" int" | ||
+ " not null, \"create\" int) %s;", | ||
enableIcebergStreaming ? "iceberg" : "", | ||
tableName, | ||
enableIcebergStreaming ? getIcebergTableConfig(tableName) : "")); | ||
SnowflakeStreamingIngestChannel channel = | ||
openChannel(tableName, OpenChannelRequest.OnErrorOption.CONTINUE); | ||
|
||
|
@@ -174,9 +215,11 @@ public void testNullValuesForNotNullColNames() throws Exception { | |
conn.createStatement() | ||
.execute( | ||
String.format( | ||
"create or replace table %s (col1 int not null, a int not null, \"a\" int not" | ||
+ " null, col2 int not null, \"col3\" int);", | ||
tableName)); | ||
"create or replace %s table %s (col1 int not null, a int not null, \"a\" int not" | ||
+ " null, col2 int not null, \"col3\" int) %s;", | ||
enableIcebergStreaming ? "iceberg" : "", | ||
tableName, | ||
enableIcebergStreaming ? getIcebergTableConfig(tableName) : "")); | ||
SnowflakeStreamingIngestChannel channel = | ||
openChannel(tableName, OpenChannelRequest.OnErrorOption.CONTINUE); | ||
|
||
|
@@ -222,7 +265,9 @@ private void testColumnNameSupported(String createTableColumnName, String ingest | |
} | ||
Assert.assertEquals(1, count); | ||
|
||
conn.createStatement().execute(String.format("alter table %s migrate;", tableName)); | ||
if (!enableIcebergStreaming) { | ||
conn.createStatement().execute(String.format("alter table %s migrate;", tableName)); | ||
} | ||
} | ||
|
||
private void testColumnNameSupported(String column) throws SQLException, InterruptedException { | ||
|
@@ -252,7 +297,12 @@ private void testInsertRowFails( | |
private String createSimpleTable(String createTableColumnName) throws SQLException { | ||
String tableName = "a" + UUID.randomUUID().toString().replace("-", "_"); | ||
String createTableSql = | ||
String.format("create table %s (%s int);", tableName, createTableColumnName); | ||
String.format( | ||
"create %s table %s (%s int) %s", | ||
enableIcebergStreaming ? "iceberg" : "", | ||
tableName, | ||
createTableColumnName, | ||
enableIcebergStreaming ? getIcebergTableConfig(tableName) : ""); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO we should refactor this to have a method that takes in the table name and column schema list only, and adds the proper prefix (iceberg table vs. table) and proper suffix (catalog and external_volume and base_location). Instead of every create table call having to worry about both these things. If this PR is good to merge am ok with this test refactoring in the next PR. Please also pick up any deferred comments from the last PR if any! |
||
conn.createStatement().execute(createTableSql); | ||
return tableName; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With our plan to run two IT suites in parallel for iceberg/non-iceberg, how will this class be run in one mode in suite 1 and another mode in suite 2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will split this into two separate tests in later PR.