[ 
https://issues.apache.org/jira/browse/BEAM-9840?focusedWorklogId=430488&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-430488
 ]

ASF GitHub Bot logged work on BEAM-9840:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 05/May/20 02:05
            Start Date: 05/May/20 02:05
    Worklog Time Spent: 10m 
      Work Description: rahul8383 commented on a change in pull request #11569:
URL: https://github.com/apache/beam/pull/11569#discussion_r419827790



##########
File path: 
sdks/java/io/hcatalog/src/test/java/org/apache/beam/sdk/io/hcatalog/SchemaUtilsTest.java
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.beam.sdk.io.hcatalog;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.beam.sdk.schemas.Schema;
+import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SchemaUtilsTest {
+  @Test
+  public void testParameterizedTypesToBeamTypes() {
+    List<FieldSchema> listOfFieldSchema = new ArrayList<>();
+    listOfFieldSchema.add(new FieldSchema("parameterizedChar", "char(10)", 
null));
+    listOfFieldSchema.add(new FieldSchema("parameterizedVarchar", 
"varchar(100)", null));
+    listOfFieldSchema.add(new FieldSchema("parameterizedDecimal", 
"decimal(30,16)", null));
+
+    Schema expectedSchema =
+        Schema.builder()
+            .addNullableField("parameterizedChar", Schema.FieldType.STRING)
+            .addNullableField("parameterizedVarchar", Schema.FieldType.STRING)
+            .addNullableField("parameterizedDecimal", Schema.FieldType.DECIMAL)

Review comment:
       Thanks @TheNeuralBit for the review.
   
   I am adding logical types in `schemas.logicaltypes` called 
`VariableLengthBytes`, `FixedLengthString`, `VariableLengthString`, 
`LogicalDecimal` as part of #11581 .
   
   I will take up the task of mapping these to logical types once my other PR 
gets merged. I also hope that #11272 get merged by then, so that I can use 
`SqlTypes.DATE` logical type. Can you please create a JIRA ticket and assign it 
to me.




----------------------------------------------------------------
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:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 430488)
    Time Spent: 1h  (was: 50m)

> Support for Parameterized Types when converting from HCatRecords to Rows in 
> HCatalogIO
> --------------------------------------------------------------------------------------
>
>                 Key: BEAM-9840
>                 URL: https://issues.apache.org/jira/browse/BEAM-9840
>             Project: Beam
>          Issue Type: Improvement
>          Components: io-java-hcatalog
>            Reporter: Rahul Patwari
>            Assignee: Rahul Patwari
>            Priority: Major
>             Fix For: 2.22.0
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> In Hive, to use CHAR and VARCHAR as the data type for a column, the types 
> have to be parameterized with the length of the character sequence. Refer 
> [https://github.com/apache/hive/blob/f37c5de6c32b9395d1b34fa3c02ed06d1bfbf6eb/serde/src/test/org/apache/hadoop/hive/serde2/typeinfo/TestTypeInfoUtils.java#L68]
> In addition, for the DECIMAL data type, custom precision and scale can be 
> provided as parameters.
> A user has faced an Exception while reading data from a table created in Hive 
> with a parameterized DECIMAL data type. Refer 
> [https://lists.apache.org/thread.html/r159012fbefce24d734096e3ec24ecd112de5f89b8029e57147d233b0%40%3Cuser.beam.apache.org%3E].
> This ticket is created to support converting from HcatRecords to Rows when 
> the HCatRecords have parameterized types.
> To Support Parameterized data types, we can make use of HcatFieldSchema. 
> Refer 
> [https://github.com/apache/hive/blob/f37c5de6c32b9395d1b34fa3c02ed06d1bfbf6eb/hcatalog/core/src/main/java/org/apache/hive/hcatalog/data/schema/HCatFieldSchema.java#L34]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to