Skip to content

Commit

Permalink
creating 1st layer partition-by field - source_ts_us
Browse files Browse the repository at this point in the history
  • Loading branch information
syook-r7 committed Aug 12, 2024
1 parent 1b59059 commit 3f34fed
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.tabular.iceberg.connect.transforms;

public interface CustomFieldConstants {
String SOURCE_TIMESTAMP_US = "source_ts_us";
String SOURCE_TIMESTAMP_MS = "source_ts_ms";
String SOURCE_TIMESTAMP_NS = "source_ts_ns";
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ private R applyWithSchema(R record) {
}
newValue.put(CdcConstants.COL_CDC, cdcMetadata);

if (value.getStruct("ts_us") != null) {
newValue.put(CustomFieldConstants.SOURCE_TIMESTAMP_US, new java.util.Date(value.getInt64("ts_us")));
}

return record.newRecord(
record.topic(),
record.kafkaPartition(),
Expand Down Expand Up @@ -155,6 +159,10 @@ private R applySchemaless(R record) {
Map<String, Object> newValue = Maps.newHashMap((Map<String, Object>) payload);
newValue.put(CdcConstants.COL_CDC, cdcMetadata);

if (value.containsKey("ts_us")) {
newValue.put(CustomFieldConstants.SOURCE_TIMESTAMP_US, value.get("ts_us"));
}

return record.newRecord(
record.topic(),
record.kafkaPartition(),
Expand Down

0 comments on commit 3f34fed

Please sign in to comment.