You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
how to read a column of LowCardinality(Nullable(string)) #326
changed the title [-]how to a column of LowCardinality(Nullable(string) [/-][+]how to read a column of LowCardinality(Nullable(string) [/+]on Sep 8, 2023
changed the title [-]how to read a column of LowCardinality(Nullable(string) [/-][+]how to read a column of LowCardinality(Nullable(string))[/+]on Sep 8, 2023
this is a insert LowCardinalityTNullableString column test case not read ,
when read a LowCardinalityTNullableString column , col == nullptr is true
/// use by LowCardinalitv(Nullable(string))voidread_lowcardinality_nullable_str(clickhouse::ColumnRef column, std::vector<std::string>& output) {
auto col = column->As<clickhouse::ColumnLowCardinalityT<clickhouse::ColumnNullableT<clickhouse::ColumnString>>>();
if (col == nullptr) {
std::cerr <<"read_lowcardinality_nullable_str col is null"<<std::endl;
return;
}
for(size_t i = 0; i < col->Size(); i++) {
auto op = col->At(i);
if (op.has_value())
output.emplace_back(*op);
else
output.emplace_back("");
}
}
the result is
read_lowcardinality_nullable_str col is null
read_lowcardinality_nullable_str col is null
read_lowcardinality_nullable_str col is null
read_lowcardinality_nullable_str col is null
read_lowcardinality_nullable_str col is null
read_lowcardinality_nullable_str col is null
read_lowcardinality_nullable_str col is null
read_lowcardinality_nullable_str col is null
...
Please check master now, most likely you've had ClientOptions::backward_compatibility_lowcardinality_as_wrapped_column set to true and that's why the LowCardinality(String) column was unwrapped into just String.
@Enmk
Thank you for your reply,
I'm pretty sure ClientOptions::backward_compatibility_lowcardinality_as_wrapped_column set to false before,maybe ColumnLowCardinalityT not work with ColumnNullableT when read ?
@Enmk Thank you for your reply, I'm pretty sure ClientOptions::backward_compatibility_lowcardinality_as_wrapped_column set to false before,maybe ColumnLowCardinalityT not work with ColumnNullableT when read ?
Activity
[-]how to a column of LowCardinality(Nullable(string) [/-][+]how to read a column of LowCardinality(Nullable(string) [/+][-]how to read a column of LowCardinality(Nullable(string) [/-][+]how to read a column of LowCardinality(Nullable(string))[/+]Enmk commentedon Sep 14, 2023
Hi @changvin ! Thanks to @den818 you can do the following:
auto col = column->As<ColumnLowCardinalityT<ColumnNullableT<ColumnString>>>();Then
col->At(0)is going to returnstd::optional<std::string>.There is a test case for it (might be a bit convoluted) right here:
clickhouse-cpp/ut/roundtrip_tests.cpp
Line 213 in 4f929e9
Enmk commentedon Sep 14, 2023
Btw, next time, please attach the code as text, not as a picture... it is much easier to play around and/or modify it like that.
changvin commentedon Sep 25, 2023
///@Enmk
//> Hi @changvin ! Thanks to @den818 you can do the following:
this is a insert LowCardinalityTNullableString column test case not read ,
when read a LowCardinalityTNullableString column , col == nullptr is true
the result is
Enmk commentedon Sep 26, 2023
Please check master now, most likely you've had
ClientOptions::backward_compatibility_lowcardinality_as_wrapped_columnset totrueand that's why theLowCardinality(String)column was unwrapped into justString.changvin commentedon Oct 11, 2023
@Enmk
Thank you for your reply,
I'm pretty sure
ClientOptions::backward_compatibility_lowcardinality_as_wrapped_columnset to false before,maybeColumnLowCardinalityTnot work withColumnNullableTwhen read ?Enmk commentedon Oct 12, 2023
Please see #339
This one confirms that it works
Perhaps, it would be helpful to know the real type of column at run-time with:
column->GetType().GetName()you can include that in your error message for debugging.