Add support for "Raw" column format for Regexp format

This commit is contained in:
Alexey Milovidov 2020-09-28 01:09:32 +03:00 committed by alesapin
parent 5674949c18
commit 2b32646231
3 changed files with 26 additions and 0 deletions

View File

@ -51,6 +51,8 @@ RegexpRowInputFormat::ColumnFormat RegexpRowInputFormat::stringToFormat(const St
return ColumnFormat::Csv;
if (format == "JSON")
return ColumnFormat::Json;
if (format == "Raw")
return ColumnFormat::Raw;
throw Exception("Unsupported column format \"" + format + "\".", ErrorCodes::BAD_ARGUMENTS);
}
@ -88,6 +90,12 @@ bool RegexpRowInputFormat::readField(size_t index, MutableColumns & columns)
else
type->deserializeAsTextJSON(*columns[index], field_buf, format_settings);
break;
case ColumnFormat::Raw:
if (parse_as_nullable)
read = DataTypeNullable::deserializeWholeText(*columns[index], field_buf, format_settings, type);
else
type->deserializeAsWholeText(*columns[index], field_buf, format_settings);
break;
default:
break;
}

View File

@ -0,0 +1 @@
abc\\ Hello, world!

View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. "$CURDIR"/../shell_config.sh
${CLICKHOUSE_CLIENT} -n --query "
DROP TABLE IF EXISTS t;
CREATE TABLE t (a String, b String) ENGINE = Memory;
"
${CLICKHOUSE_CLIENT} --format_regexp_escaping_rule 'Raw' --format_regexp '^(.+?) separator (.+?)$' --query '
INSERT INTO t FORMAT Regexp abc\ separator Hello, world!'
${CLICKHOUSE_CLIENT} -n --query "
SELECT * FROM t;
DROP TABLE t;
"