Fixed failing tests

This commit is contained in:
Alfonso Martinez 2022-10-26 11:50:45 +02:00
parent 8ef07bac89
commit 241049763b
4 changed files with 32 additions and 4 deletions

View File

@ -1330,12 +1330,23 @@ public:
// We use insertResultToFixedStringColumn in case we are inserting raw data in a FixedString column // We use insertResultToFixedStringColumn in case we are inserting raw data in a FixedString column
static bool insertResultToFixedStringColumn(IColumn & dest, const Element & element, std::string_view) static bool insertResultToFixedStringColumn(IColumn & dest, const Element & element, std::string_view)
{ {
ColumnFixedString & col_str = assert_cast<ColumnFixedString &>(dest); ColumnFixedString::Chars chars;
auto & chars = col_str.getChars();
WriteBufferFromVector<ColumnFixedString::Chars> buf(chars, AppendModeTag()); WriteBufferFromVector<ColumnFixedString::Chars> buf(chars, AppendModeTag());
traverse(element, buf); traverse(element, buf);
buf.finalize(); buf.finalize();
col_str.insertDefault();
auto & col_str = assert_cast<ColumnFixedString &>(dest);
if (chars.size() > col_str.getN())
return false;
chars.push_back(0);
std::string str = reinterpret_cast<const char *>(chars.data());
auto padded_str = str + std::string(col_str.getN() - std::min(col_str.getN(), str.length()), '\0');
col_str.insertData(str.data(), str.size());
return true; return true;
} }

View File

@ -1,3 +1,2 @@
-- Tags: no-fasttest
SELECT JSONExtract('{"a" : {"b" : {"c" : 1, "d" : "str"}}}', 'Tuple( a LowCardinality(String), b LowCardinality(String), c LowCardinality(String), d LowCardinality(String))'); SELECT JSONExtract('{"a" : {"b" : {"c" : 1, "d" : "str"}}}', 'Tuple( a LowCardinality(String), b LowCardinality(String), c LowCardinality(String), d LowCardinality(String))');
SELECT JSONExtract('{"a" : {"b" : {"c" : 1, "d" : "str"}}}', 'Tuple( a String, b LowCardinality(String), c LowCardinality(String), d LowCardinality(String))'); SELECT JSONExtract('{"a" : {"b" : {"c" : 1, "d" : "str"}}}', 'Tuple( a String, b LowCardinality(String), c LowCardinality(String), d LowCardinality(String))');

View File

@ -0,0 +1,10 @@
\0\0\0\0\0\0\0\0\0\0\0
{"a":123456}
\0\0\0\0\0
123456
\0\0\0\0\0
123456
\0\0\0\0\0
\0\0\0\0\0
131231
131231

View File

@ -0,0 +1,8 @@
SELECT JSONExtract('{"a": 123456}', 'FixedString(11)');
SELECT JSONExtract('{"a": 123456}', 'FixedString(12)');
SELECT JSONExtract('{"a": "123456"}', 'a', 'FixedString(5)');
SELECT JSONExtract('{"a": "123456"}', 'a', 'FixedString(6)');
SELECT JSONExtract('{"a": 123456}', 'a', 'FixedString(5)');
SELECT JSONExtract('{"a": 123456}', 'a', 'FixedString(6)');
SELECT JSONExtract(materialize('{"a": 131231}'), 'a', 'LowCardinality(FixedString(5))') FROM numbers(2);
SELECT JSONExtract(materialize('{"a": 131231}'), 'a', 'LowCardinality(FixedString(6))') FROM numbers(2);