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

Set createdon in BlobMetadata and is_iceberg in Drop Channel request #845

Merged
merged 1 commit into from
Sep 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 @@ -142,7 +142,8 @@ static <T> Blob constructBlobAndMetadata(
chunkMetadataBuilder
.setMajorVersion(Constants.PARQUET_MAJOR_VERSION)
.setMinorVersion(Constants.PARQUET_MINOR_VERSION)
.setCreatedOn(0L)
// set createdOn in seconds
.setCreatedOn(System.currentTimeMillis() / 1000)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this? Blobs already have create time in its property and its cheaper to get it there than to query metadata

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For having consistent metadata across XP-based DML inserts into iceberg tables and SDK-based inserts into iceberg tables.

.setExtendedMetadataSize(-1L);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,25 @@ class DropChannelRequestInternal implements IStreamingIngestRequest {
@JsonProperty("client_sequencer")
Long clientSequencer;

@JsonProperty("is_iceberg")
boolean isIceberg;

DropChannelRequestInternal(
String requestId,
String role,
String database,
String schema,
String table,
String channel,
boolean isIceberg,
Long clientSequencer) {
this.requestId = requestId;
this.role = role;
this.database = database;
this.schema = schema;
this.table = table;
this.channel = channel;
this.isIceberg = isIceberg;
this.clientSequencer = clientSequencer;
}

Expand Down Expand Up @@ -74,6 +79,10 @@ String getSchema() {
return schema;
}

boolean isIceberg() {
return isIceberg;
}

Long getClientSequencer() {
return clientSequencer;
}
Expand All @@ -86,7 +95,7 @@ String getFullyQualifiedTableName() {
public String getStringForLogging() {
return String.format(
"DropChannelRequest(requestId=%s, role=%s, db=%s, schema=%s, table=%s, channel=%s,"
+ " clientSequencer=%s)",
requestId, role, database, schema, table, channel, clientSequencer);
+ " isIceberg=%s, clientSequencer=%s)",
requestId, role, database, schema, table, channel, isIceberg, clientSequencer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ public void dropChannel(DropChannelRequest request) {
request.getSchemaName(),
request.getTableName(),
request.getChannelName(),
this.isIcebergMode,
request instanceof DropChannelVersionRequest
? ((DropChannelVersionRequest) request).getClientSequencer()
: null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@
import net.snowflake.ingest.utils.Constants;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

@RunWith(Parameterized.class)
public class SnowflakeServiceClientTest {
@Parameterized.Parameters(name = "isIceberg: {0}")
public static Object[] isIceberg() {
return new Object[] {false, true};
}

@Parameterized.Parameter public boolean isIceberg;

private SnowflakeServiceClient snowflakeServiceClient;

@Before
Expand Down Expand Up @@ -50,7 +60,7 @@ public void testOpenChannel() throws IngestResponseException, IOException {
"test_table",
"test_channel",
Constants.WriteMode.CLOUD_STORAGE,
false,
isIceberg,
"test_offset_token");
OpenChannelResponse openChannelResponse =
snowflakeServiceClient.openChannel(openChannelRequest);
Expand All @@ -72,7 +82,14 @@ public void testOpenChannel() throws IngestResponseException, IOException {
public void testDropChannel() throws IngestResponseException, IOException {
DropChannelRequestInternal dropChannelRequest =
new DropChannelRequestInternal(
"request_id", "test_role", "test_db", "test_schema", "test_table", "test_channel", 0L);
"request_id",
"test_role",
"test_db",
"test_schema",
"test_table",
"test_channel",
isIceberg,
0L);
DropChannelResponse dropChannelResponse =
snowflakeServiceClient.dropChannel(dropChannelRequest);
assert dropChannelResponse.getStatusCode() == 0L;
Expand Down
Loading