From commits-return-9393-archive-asf-public=cust-asf.ponee.io@hudi.apache.org Fri Jan 10 02:48:49 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 4039E18063F for ; Fri, 10 Jan 2020 03:48:49 +0100 (CET) Received: (qmail 29559 invoked by uid 500); 10 Jan 2020 02:48:48 -0000 Mailing-List: contact commits-help@hudi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hudi.apache.org Delivered-To: mailing list commits@hudi.apache.org Received: (qmail 29549 invoked by uid 99); 10 Jan 2020 02:48:48 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Jan 2020 02:48:48 +0000 From: GitBox To: commits@hudi.apache.org Subject: [GitHub] [incubator-hudi] OpenOpened commented on a change in pull request #1188: [HUDI-502] provide a custom time zone definition for TimestampBasedKeyGenerator Message-ID: <157862452843.19648.8427126575457787569.gitbox@gitbox.apache.org> References: In-Reply-To: Date: Fri, 10 Jan 2020 02:48:48 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit OpenOpened commented on a change in pull request #1188: [HUDI-502] provide a custom time zone definition for TimestampBasedKeyGenerator URL: https://github.com/apache/incubator-hudi/pull/1188#discussion_r365052896 ########## File path: hudi-utilities/src/test/java/org/apache/hudi/utilities/TestTimestampBasedKeyGenerator.java ########## @@ -0,0 +1,89 @@ +/* + * 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 org.apache.hudi.utilities; + +import org.apache.avro.Schema; +import org.apache.avro.generic.GenericRecord; +import org.apache.hudi.DataSourceWriteOptions; +import org.apache.hudi.common.model.HoodieKey; +import org.apache.hudi.common.util.SchemaTestUtil; +import org.apache.hudi.common.util.TypedProperties; +import org.apache.hudi.utilities.keygen.TimestampBasedKeyGenerator; +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; + +import static org.junit.Assert.assertEquals; + +public class TestTimestampBasedKeyGenerator { + private Schema schema = SchemaTestUtil.getTimestampEvolvedSchema(); + private GenericRecord baseRecord = null; + + public TestTimestampBasedKeyGenerator() throws IOException { + } + + @Before + public void initialize() throws IOException { + baseRecord = SchemaTestUtil + .generateAvroRecordFromJson(schema, 1, "001", "f1"); + } + + private TypedProperties getKeyConfig(String recordKeyFieldName, String partitionPathField, String hiveStylePartitioning) { + TypedProperties props = new TypedProperties(); + props.setProperty(DataSourceWriteOptions.RECORDKEY_FIELD_OPT_KEY(), recordKeyFieldName); + props.setProperty(DataSourceWriteOptions.PARTITIONPATH_FIELD_OPT_KEY(), partitionPathField); + props.setProperty(DataSourceWriteOptions.HIVE_STYLE_PARTITIONING_OPT_KEY(), hiveStylePartitioning); + props.setProperty("hoodie.deltastreamer.keygen.timebased.timestamp.type", "EPOCHMILLISECONDS"); + props.setProperty("hoodie.deltastreamer.keygen.timebased.output.dateformat", "yyyy-MM-dd hh"); + props.setProperty("hoodie.deltastreamer.keygen.timebased.timezone", "GMT+8:00"); + return props; + } + + private TypedProperties getKeyConfig2(String recordKeyFieldName, String partitionPathField, String hiveStylePartitioning) { + TypedProperties props = getKeyConfig(recordKeyFieldName, partitionPathField, hiveStylePartitioning); + props.setProperty("hoodie.deltastreamer.keygen.timebased.timezone", "GMT"); + return props; + } + + private TypedProperties getKeyConfig3(String recordKeyFieldName, String partitionPathField, String hiveStylePartitioning) { + TypedProperties props = getKeyConfig(recordKeyFieldName, partitionPathField, hiveStylePartitioning); + props.setProperty("hoodie.deltastreamer.keygen.timebased.timestamp.type", "DATE_STRING"); + props.setProperty("hoodie.deltastreamer.keygen.timebased.input.dateformat", "yyyy-MM-dd hh:mm:ss"); + props.setProperty("hoodie.deltastreamer.keygen.timebased.timezone", "GMT+8:00"); + return props; + } Review comment: thank's reply, i will fix it. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services