ClickHouse/spark-clickhouse-connector

Failed to query fields of type FixedString

eye-gu opened this issue · 5 comments

eye-gu commented
com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot access contents of TextNode as binary due to broken Base64 encoding: Unexpected end of base64-encoded String: base64 variant 'MIME-NO-LINEFEEDS' expects padding (one or more '=' characters) at the end. This Base64Variant might have been incorrectly configured
	at com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:67)
	at com.fasterxml.jackson.databind.node.TextNode.getBinaryValue(TextNode.java:78)
	at com.fasterxml.jackson.databind.node.TextNode.binaryValue(TextNode.java:89)
	at xenon.clickhouse.read.format.ClickHouseJsonReader.decodeValue(ClickHouseJsonReader.scala:81)
	at xenon.clickhouse.read.format.ClickHouseJsonReader.decode(ClickHouseJsonReader.scala:48)
	at xenon.clickhouse.read.format.ClickHouseJsonReader.decode(ClickHouseJsonReader.scala:33)
	at xenon.clickhouse.read.ClickHouseReader.get(ClickHouseReader.scala:89)
	at xenon.clickhouse.read.ClickHouseReader.get(ClickHouseReader.scala:29)

Seems like you are storing binary data instead of UTF-8 encoded string using FixedString, mind providing more details about your use case and failed queries?

eye-gu commented

image
image

DBeaver sql : SELECT column_fixedString from zhouwq.alltype;
spark sql : select column_fixedString from clickhouse.zhouwq.alltype;
spark version: spark-3.3.0-bin-hadoop2
column_fixedString of type FixedString(2) data is all ab

eye-gu commented

I found that in the 'fromClickHouseType' method, the 'FixedString' type is mapped to a 'BinaryType', why is it not a 'StringType'?

technically, ClickHouse's FixedString and String are allowed to store any bytes, seems we need to make the type mapping configurable

made a PR for this