-
Notifications
You must be signed in to change notification settings - Fork 76
Spark: Binary reader supports String for Array/Map reading #395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spark: Binary reader supports String for Array/Map reading #395
Conversation
possible to add test cases? |
val arrayValue = value.asInstanceOf[ClickHouseArraySequence] | ||
val convertedArray = Array.tabulate(arrayValue.length) { i => | ||
decodeValue( | ||
arrayValue.getValue(i, createClickHouseValue(null, _dataType)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createClickHouseValue(null, _dataType)
for every element looks costly. does clickhouse-jave provide constant variables for default null values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getValue
needs a corresponding ClickHouseValue
container based on data type (e.g. ClickHouseIntegerValue
, ClickHouseLongValue
). Unfortunately, there's no factory method to create it based on input type. createClickHouseValue
creates empty containers based on input data type.
case IntegerType => ClickHouseIntegerValue.of(if (isNull) 0 else rawValue.asInstanceOf[Int]) | ||
case LongType => ClickHouseLongValue.of(if (isNull) 0L else rawValue.asInstanceOf[Long]) | ||
case DoubleType => ClickHouseDoubleValue.of(if (isNull) 0.0 else rawValue.asInstanceOf[Double]) | ||
case FloatType => ClickHouseFloatValue.of(if (isNull) 0.0f else rawValue.asInstanceOf[Float]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, can we use the clickhouse-java defined default value variable instead of hardcoding it for each data type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good one. will fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call ofNull/ofEmpty for each ClickHouse value type provided.
Not sure which failures you encountered, it works well on my local env, anyway, manually testing is also good. |
@pan3793 would appreciate your review again. |
Summary
Fix binary reader String handling in Arrays and Map (e.g.,
Array(String)
,Map(String, String)
).