pinot icon indicating copy to clipboard operation
pinot copied to clipboard

Support fill null value with default value when column is not present in record

Open troywinter opened this issue 5 years ago • 8 comments

We are getting Caught exception while transforming the record: when ingesting json data from kafka, it will throw java.lang.ClassCastException: null and no stack trace will be printed. The problem from json record is, json payload is not providing full columns from schema, some columns are missing, in this situation, if pinot is getting an value from GenericRow, it will be null, then add that row to index, it probably will cast a null value.

This situation should be properly handled if payload is missing a column, it should be filled with column's default value.

troywinter avatar Apr 27 '21 03:04 troywinter

Pinot should be able to fill the default value. Not sure what has caused the exception. Can you please share the table config and schema? Have you configured any record transform function?

Jackie-Jiang avatar Apr 27 '21 04:04 Jackie-Jiang

Pinot should be able to fill the default value. Not sure what has caused the exception. Can you please share the table config and schema? Have you configured any record transform function?

"ingestionConfig": {
      "transformConfigs": [
        {
          "columnName": "is_whale_test",
          "transformFunction": "Groovy({group_name ==~ /^.*whale_test.*$/ ? 1 : 0}, group_name)"
        }
      ]
    },

here is the transform config, I don't think the exception is from transform stage, from the code structure, it could be caused in the index function call, like when cast to some type, in my case, group_name is always present in any message.

troywinter avatar Apr 27 '21 05:04 troywinter

Can you please check all the logs? When the exception first occur, it should log the full stack trace. You may also restart the server so that the first exception after restart logs the full stack trace. Casting null to other type won't cause exception. It's more likely we are trying to ingest values of unsupported type (e.g. some json class).

Jackie-Jiang avatar Apr 27 '21 17:04 Jackie-Jiang

Can you please check all the logs? When the exception first occur, it should log the full stack trace. You may also restart the server so that the first exception after restart logs the full stack trace. Casting null to other type won't cause exception. It's more likely we are trying to ingest values of unsupported type (e.g. some json class).

From the log, the ingestion already complete, group_name is string, and it has produced the right column transform result, that exception catching include transform and index call, it could from transform call or index call.

troywinter avatar Apr 28 '21 03:04 troywinter

Good point. We should probably isolate the transform and index and catch exception separately. Does this exception occur multiple times or just once? Is it reproducible? I need the full stack-trace to identify the issue.

Jackie-Jiang avatar Apr 28 '21 05:04 Jackie-Jiang

Good point. We should probably isolate the transform and index and catch exception separately. Does this exception occur multiple times or just once? Is it reproducible? I need the full stack-trace to identify the issue.

java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
	at org.apache.pinot.core.data.recordtransformer.SanitizationTransformer.transform(SanitizationTransformer.java:71) ~[pinot-all-0.7.0-SNAPSHOT-jar-with-dependencies.jar:0.7.0-SNAPSHOT-255202ec4fc7df2283f7c275d8e9025a26cf3274]
	at org.apache.pinot.core.data.recordtransformer.CompositeTransformer.transform(CompositeTransformer.java:82) ~[pinot-all-0.7.0-SNAPSHOT-jar-with-dependencies.jar:0.7.0-SNAPSHOT-255202ec4fc7df2283f7c275d8e9025a26cf3274]
	at org.apache.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManager.processStreamEvents(LLRealtimeSegmentDataManager.java:491) [pinot-all-0.7.0-SNAPSHOT-jar-with-dependencies.jar:0.7.0-SNAPSHOT-255202ec4fc7df2283f7c275d8e9025a26cf3274]
	at org.apache.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManager.consumeLoop(LLRealtimeSegmentDataManager.java:402) [pinot-all-0.7.0-SNAPSHOT-jar-with-dependencies.jar:0.7.0-SNAPSHOT-255202ec4fc7df2283f7c275d8e9025a26cf3274]
	at org.apache.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManager$PartitionConsumer.run(LLRealtimeSegmentDataManager.java:538) [pinot-all-0.7.0-SNAPSHOT-jar-with-dependencies.jar:0.7.0-SNAPSHOT-255202ec4fc7df2283f7c275d8e9025a26cf3274]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_275]

Here is the full exception from log, it's not from transformation I defined in the table, but it's from the Sanitization transform for multivalue columns, the problem is we have mixed multi value mixing string and integer, so a cast to string will fail.

To properly handle this situation, should we convert value to String not cast? What do you think?

troywinter avatar Apr 28 '21 06:04 troywinter

For a multi-valued column, the input array must have all the values in the same type because we use the type of the first element to determine the source array type. If the column type is multi-value STRING, we might be able to solve it by always using toString() for the type casting. But we should avoid having mixed type data in the same input array. I'll submit a fix for the SanitizationTransformer to use toString() for the type casting.

Jackie-Jiang avatar Apr 28 '21 20:04 Jackie-Jiang

Fixed in #6863

Jackie-Jiang avatar Apr 29 '21 20:04 Jackie-Jiang