Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Drill >> mail # dev >> Thread for discussing CAST functionality


Copy link to this message
-
RE: Thread for discussing CAST functionality
Hi All,
I have made a quick naïve implementation of the cast functionality so that we have something on which we can start discussions on.
I am getting the closest match of called function. Now I need a way to convert the function call to the new data types.
Can anyone point how can we convert the function call.

https://github.com/yashs360/incubator-drill-casting/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/resolver/OperatorFunctionResolver.java

Currently I am returning the best matched function directly. Below are the results of my code so far.

- Yash

Provided functions for add (MathFunctions.java):
------------------------------------------------------------
ADD( INT, INT)
ADD(BIGINT, BIGINT)
ADD(FLOAT4, FLOAT4)
ADD( FLOAT8, FLOAT8)

Incoming function call :
-----------------------------
INT(FLOAT4, FLOAT4)
ADD(FLOAT4, INT)
ADD( INT, FLOAT4)

RESULTS:
-----------------

0: jdbc:drill:schema=parquet-local> select 2.3 + 2.2 as cast_result from "sample-data/region.parquet";
+--------------+
| CAST_RESULT  |
+--------------+
| 4.5          |
| 4.5          |
| 4.5          |
| 4.5          |
| 4.5          |
+--------------+
0: jdbc:drill:schema=parquet-local> select 2.3 + 2 as cast_result from "sample-data/region.parquet";
+--------------+
| CAST_RESULT  |
+--------------+
| 4.3          |
| 4.3          |
| 4.3          |
| 4.3          |
| 4.3          |
+--------------+
0: jdbc:drill:schema=parquet-local> select 2 + 2.3 as cast_result from "sample-data/region.parquet";
Caused by: org.apache.drill.exec.rpc.RpcException: [error_id: "b69f5eaf-b592-428b-8011-bab75a327191"
endpoint {
  address: "localhost"
  user_port: 31010
  bit_port: 31011
}
error_type: 0
message: "Screen received stop request sent. < SchemaChangeException:[ Failure while attempting to load generated class ] < ClassTransformationException:[ Failure generating transformation classes for value: \n \npackage org.apache.drill.exec.test.generated;\n\nimport org.apache.drill.exec.exception.SchemaChangeException;\nimport org.apache.drill.exec.expr.holders.BigIntHolder;\nimport org.apache.drill.exec.expr.holders.Float8Holder;\nimport org.apache.drill.exec.ops.FragmentContext;\nimport org.apache.drill.exec.record.RecordBatch;\nimport org.apache.drill.exec.vector.BigIntVector;\n\npublic class Gen5 {\n\n    BigIntVector vv3;\n\n    public void doSetup(FragmentContext context, RecordBatch incoming, RecordBatch outgoing)\n        throws SchemaChangeException\n    {\n        {\n            /** start SETUP for function add **/ \n            {\n                 {}\n            }\n            /** end SETUP for function add **/ \n            Object tmp4 = (outgoing).getValueAccessorById(0, BigIntVector.class).getValueVector();\n            if (tmp4 == null) {\n                throw new SchemaChangeException(\"Failure while loading vector vv3 with id: TypedFieldId [type=minor_type: BIGINT\\nmode: REQUIRED\\n, fieldId=0, isSuperReader=false].\");\n            }\n            vv3 = ((BigIntVector) tmp4);\n        }\n    }\n\n    public void doEval(int inIndex, int outIndex)\n        throws SchemaChangeException\n    {\n        {\n            BigIntHolder out0 = new BigIntHolder();\n            out0 .value = 2L;\n            Float8Holder out1 = new Float8Holder();\n            out1 .value = 2.2D;\n            Float8Holder out2 = new Float8Holder();\n            {\n                final Float8Holder out = new Float8Holder();\n                BigIntHolder left = out0;\n                Float8Holder right = out1;\n                 \n    out.value = left.value + right.value;\n \n                out2 = out;\n            }\n            vv3 .getMutator().set((outIndex), out2 .value);\n        }\n    }\n\n}\n ] < CompileException:[ Line 50, Column 34: No applicable constructor/method found for actual parameters \"int, double\"; candidates are: \"/*default*/ void org.apache.drill.exec.vector.BigIntVector$Mutator.set(int, org.apache.drill.exec.expr.holders.NullableBigIntHolder)\", \"public void org.apache.drill.exec.vector.BigIntVector$Mutator.set(int, org.apache.drill.exec.expr.holders.BigIntHolder)\", \"public void org.apache.drill.exec.vector.BigIntVector$Mutator.set(int, long)\" ]"
]
        at org.apache.drill.sql.client.full.BatchListener.resultArrived(BatchListener.java:52)
        at org.apache.drill.exec.rpc.user.QueryResultHandler.batchArrived(QueryResultHandler.java:75)
        at org.apache.drill.exec.rpc.user.UserClient.handle(UserClient.java:79)
        at org.apache.drill.exec.rpc.BasicClientWithConnection.handle(BasicClientWithConnection.java:48)
        at org.apache.drill.exec.rpc.BasicClientWithConnection.handle(BasicClientWithConnection.java:33)
        at org.apache.drill.exec.rpc.RpcBus$InboundHandler.decode(RpcBus.java:142)
        at org.apache.drill.exec.rpc.RpcBus$InboundHandler.decode(RpcBus.java:127)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89)
        at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:334)
        at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:320)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
        at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:334)
        at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:320)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:173)
        at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:334)
        at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:320)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785)
        at io.netty.channel.nio.Abstr
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB