[
https://issues.apache.org/jira/browse/DRILL-4868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15762492#comment-15762492
]
ASF GitHub Bot commented on DRILL-4868:
---------------------------------------
Github user bitblender commented on a diff in the pull request:
https://github.com/apache/drill/pull/695#discussion_r93133495
--- Diff:
contrib/storage-hive/core/src/main/codegen/templates/ObjectInspectorHelper.java
---
@@ -172,48 +172,35 @@ public static JBlock getDrillObject(JCodeModel m,
ObjectInspector oi,
booleanJC._then().assign(returnValueHolder.ref("value"),
JExpr.lit(1));
booleanJC._else().assign(returnValueHolder.ref("value"),
JExpr.lit(0));
- <#elseif entry.hiveType == "VARCHAR">
- JVar data =
jc._else().decl(m.directClass(byte[].class.getCanonicalName()), "data",
- castedOI.invoke("getPrimitiveJavaObject").arg(returnValue)
+ <#elseif entry.hiveType == "VARCHAR" || entry.hiveType == "CHAR"
|| entry.hiveType == "STRING" || entry.hiveType == "BINARY">
+ <#if entry.hiveType == "VARCHAR">
+ JVar data =
jc._else().decl(m.directClass(byte[].class.getCanonicalName()), "data",
+
castedOI.invoke("getPrimitiveJavaObject").arg(returnValue)
.invoke("getValue")
.invoke("getBytes"));
-
- jc._else().add(returnValueHolder.ref("buffer")
- .invoke("setBytes").arg(JExpr.lit(0)).arg(data));
-
-
- jc._else().assign(returnValueHolder.ref("start"),
JExpr.lit(0));
- jc._else().assign(returnValueHolder.ref("end"),
data.ref("length"));
-
<#elseif entry.hiveType == "CHAR">
JVar data =
jc._else().decl(m.directClass(byte[].class.getCanonicalName()), "data",
- castedOI.invoke("getPrimitiveJavaObject").arg(returnValue)
- .invoke("getStrippedValue")
- .invoke("getBytes"));
-
- jc._else().add(returnValueHolder.ref("buffer")
- .invoke("setBytes").arg(JExpr.lit(0)).arg(data));
-
-
- jc._else().assign(returnValueHolder.ref("start"),
JExpr.lit(0));
- jc._else().assign(returnValueHolder.ref("end"),
data.ref("length"));
-
- <#elseif entry.hiveType == "STRING">
- JVar data =
jc._else().decl(m.directClass(byte[].class.getCanonicalName()), "data",
- castedOI.invoke("getPrimitiveJavaObject").arg(returnValue)
+
castedOI.invoke("getPrimitiveJavaObject").arg(returnValue)
+ .invoke("getStrippedValue")
+ .invoke("getBytes"));
+ <#elseif entry.hiveType == "STRING">
+ JVar data =
jc._else().decl(m.directClass(byte[].class.getCanonicalName()), "data",
+
castedOI.invoke("getPrimitiveJavaObject").arg(returnValue)
.invoke("getBytes"));
- jc._else().add(returnValueHolder.ref("buffer")
- .invoke("setBytes").arg(JExpr.lit(0)).arg(data));
- jc._else().assign(returnValueHolder.ref("start"),
JExpr.lit(0));
- jc._else().assign(returnValueHolder.ref("end"),
data.ref("length"));
- <#elseif entry.hiveType == "BINARY">
+ <#elseif entry.hiveType == "BINARY">
+ JVar data =
jc._else().decl(m.directClass(byte[].class.getCanonicalName()), "data",
+
castedOI.invoke("getPrimitiveJavaObject").arg(returnValue));
+ </#if>
- JVar data =
jc._else().decl(m.directClass(byte[].class.getCanonicalName()), "data",
- castedOI.invoke("getPrimitiveJavaObject").arg(returnValue));
- jc._else().add(returnValueHolder.ref("buffer")
+ JConditional jnullif = jc._else()._if(data.eq(JExpr._null()));
+ jnullif._then().assign(returnValueHolder.ref("isSet"),
JExpr.lit(0));
--- End diff --
Why is isSet set to 0 here ?
> Hive functions should update writerIndex accordingly when return binary type
> ----------------------------------------------------------------------------
>
> Key: DRILL-4868
> URL: https://issues.apache.org/jira/browse/DRILL-4868
> Project: Apache Drill
> Issue Type: Bug
> Reporter: Chunhui Shi
> Assignee: Chunhui Shi
>
> unhex is a Hive function. the returned binary buffer could not be consumed by
> convert_from as shown below.
> 0: jdbc:drill:zk=10.10.88.128:5181> select
> convert_from(unhex('0a5f710b'),'int_be') from (values(1));
> Error: SYSTEM ERROR: IndexOutOfBoundsException: readerIndex(0) + length(4)
> exceeds writerIndex(0): DrillBuf[31], udle: [25 0..1024]
> Fragment 0:0
> [Error Id: 5e72ce4a-6164-4260-8317-ca2bb6325013 on atsqa4-128.qa.lab:31010]
> (state=,code=0)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)