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

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

                Author: ASF GitHub Bot
            Created on: 14/May/20 04:11
            Start Date: 14/May/20 04:11
    Worklog Time Spent: 10m 
      Work Description: rahul8383 commented on a change in pull request #11581:
URL: https://github.com/apache/beam/pull/11581#discussion_r424860201



##########
File path: 
sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/logicaltypes/LogicalDecimal.java
##########
@@ -0,0 +1,69 @@
+/*
+ * 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.schemas.logicaltypes;
+
+import static 
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkArgument;
+
+import java.math.BigDecimal;
+import org.apache.beam.sdk.annotations.Experimental;
+import org.apache.beam.sdk.schemas.Schema;
+import org.apache.beam.sdk.values.Row;
+
+/** A LogicalType representing a Decimal type with custom precision and scale. 
*/
+@Experimental(Experimental.Kind.SCHEMAS)
+public class LogicalDecimal extends 
IdenticalBaseTAndInputTLogicalType<BigDecimal> {
+  public static final String IDENTIFIER = "beam:logical_type:decimal:v1";
+  private static final Schema schema =
+      
Schema.builder().addInt32Field("precision").addInt32Field("scale").build();
+  private final int precision;
+  private final int scale;
+
+  private LogicalDecimal(int precision, int scale) {
+    super(
+        IDENTIFIER,
+        Schema.FieldType.row(schema),
+        Row.withSchema(schema).addValues(precision, scale).build(),
+        Schema.FieldType.STRING);

Review comment:
       @TheNeuralBit Modified `RowCoderTest.testLogicalType()` which exercises 
coder for the standard logical types.




----------------------------------------------------------------
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: 432978)
    Time Spent: 2h 20m  (was: 2h 10m)

> NPE in Calcite dialect when input PCollection has logical type in schema, 
> from JdbcIO Transform
> -----------------------------------------------------------------------------------------------
>
>                 Key: BEAM-8307
>                 URL: https://issues.apache.org/jira/browse/BEAM-8307
>             Project: Beam
>          Issue Type: Bug
>          Components: dsl-sql, io-java-jdbc
>    Affects Versions: 2.15.0
>            Reporter: Rahul Patwari
>            Assignee: Rahul Patwari
>            Priority: Major
>         Attachments: exception_sqlTransform.txt
>
>          Time Spent: 2h 20m
>  Remaining Estimate: 0h
>
> An exception is thrown when SqlTransform is used with JdbcIO.
> Schema of the Source Table:
> _CREATE TABLE actor (_
>  _actor_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,_
>  _first_name VARCHAR(45) NOT NULL,_
>  _last_name VARCHAR(45) NOT NULL,_
>  _last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE 
> CURRENT_TIMESTAMP,_
>  _PRIMARY KEY (actor_id),_
>  _KEY idx_actor_last_name (last_name)_
>  _)ENGINE=InnoDB DEFAULT CHARSET=utf8;_ 
>  
> Many of the Jdbc Types are converted to Logical_Types in Beam.
> Refer: 
> [https://github.com/apache/beam/blob/113461a4275eb28a101e416897ccd607aa51f83f/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/SchemaUtil.java#L102]
> The initial observation is that this code: 
> [https://github.com/apache/beam/blob/113461a4275eb28a101e416897ccd607aa51f83f/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/utils/CalciteUtils.java#L207]
>  is returning null.
>  
> PFA [^exception_sqlTransform.txt]



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

Reply via email to