Fix comments

This commit is contained in:
avogar 2022-05-19 10:13:44 +00:00
parent a71f9eb9e4
commit f69c3175af
13 changed files with 60 additions and 43 deletions

View File

@ -2516,6 +2516,7 @@ protected:
} }
bool useDefaultImplementationForNulls() const override { return false; } bool useDefaultImplementationForNulls() const override { return false; }
/// CAST(Nothing, T) -> T
bool useDefaultImplementationForNothing() const override { return false; } bool useDefaultImplementationForNothing() const override { return false; }
bool useDefaultImplementationForConstants() const override { return true; } bool useDefaultImplementationForConstants() const override { return true; }
bool useDefaultImplementationForLowCardinalityColumns() const override { return false; } bool useDefaultImplementationForLowCardinalityColumns() const override { return false; }

View File

@ -51,6 +51,9 @@ public:
} }
bool useDefaultImplementationForNulls() const override { return false; } bool useDefaultImplementationForNulls() const override { return false; }
/// It's possible if expression_actions contains function that don't use
/// default implementation for Nothing.
/// Example: arrayMap(x -> CAST(x, 'UInt8'), []);
bool useDefaultImplementationForNothing() const override { return false; } bool useDefaultImplementationForNothing() const override { return false; }
private: private:
@ -119,6 +122,9 @@ public:
String getName() const override { return "FunctionCapture"; } String getName() const override { return "FunctionCapture"; }
bool useDefaultImplementationForNulls() const override { return false; } bool useDefaultImplementationForNulls() const override { return false; }
/// It's possible if expression_actions contains function that don't use
/// default implementation for Nothing and one of captured columns can be Nothing
/// Example: SELECT arrayMap(x -> [x, arrayElement(y, 0)], []), [] as y
bool useDefaultImplementationForNothing() const override { return false; } bool useDefaultImplementationForNothing() const override { return false; }
bool useDefaultImplementationForLowCardinalityColumns() const override { return false; } bool useDefaultImplementationForLowCardinalityColumns() const override { return false; }
@ -249,6 +255,7 @@ public:
String getName() const override { return name; } String getName() const override { return name; }
bool useDefaultImplementationForNulls() const override { return false; } bool useDefaultImplementationForNulls() const override { return false; }
/// See comment in ExecutableFunctionCapture.
bool useDefaultImplementationForNothing() const override { return false; } bool useDefaultImplementationForNothing() const override { return false; }
bool useDefaultImplementationForLowCardinalityColumns() const override { return false; } bool useDefaultImplementationForLowCardinalityColumns() const override { return false; }
DataTypePtr getReturnTypeImpl(const ColumnsWithTypeAndName &) const override { return return_type; } DataTypePtr getReturnTypeImpl(const ColumnsWithTypeAndName &) const override { return return_type; }

View File

@ -225,8 +225,9 @@ ColumnPtr IExecutableFunction::defaultImplementationForNothing(
getName(), getName(),
result_type->getName()); result_type->getName());
return ColumnConst::create(ColumnNothing::create(1), input_rows_count); if (input_rows_count > 0)
throw Exception(ErrorCodes::ILLEGAL_COLUMN, "Cannot create non-empty column with type Nothing");
return ColumnNothing::create(0);
} }
ColumnPtr IExecutableFunction::executeWithoutLowCardinalityColumns( ColumnPtr IExecutableFunction::executeWithoutLowCardinalityColumns(

View File

@ -20,6 +20,7 @@ public:
} }
bool useDefaultImplementationForNulls() const override { return false; } bool useDefaultImplementationForNulls() const override { return false; }
/// array(..., Nothing, ...) -> Array(..., Nothing, ...)
bool useDefaultImplementationForNothing() const override { return false; } bool useDefaultImplementationForNothing() const override { return false; }
bool useDefaultImplementationForConstants() const override { return true; } bool useDefaultImplementationForConstants() const override { return true; }

View File

@ -7,6 +7,12 @@
namespace DB namespace DB
{ {
namespace ErrorCodes
{
extern const int ILLEGAL_COLUMN;
}
namespace namespace
{ {
@ -33,7 +39,6 @@ public:
size_t getNumberOfArguments() const override { return 1; } size_t getNumberOfArguments() const override { return 1; }
bool useDefaultImplementationForNulls() const override { return false; } bool useDefaultImplementationForNulls() const override { return false; }
bool useDefaultImplementationForNothing() const override { return false; }
bool useDefaultImplementationForConstants() const override { return true; } bool useDefaultImplementationForConstants() const override { return true; }
ColumnNumbers getArgumentsThatDontImplyNullableReturnType(size_t /*number_of_arguments*/) const override { return {0}; } ColumnNumbers getArgumentsThatDontImplyNullableReturnType(size_t /*number_of_arguments*/) const override { return {0}; }
@ -46,6 +51,9 @@ public:
{ {
const ColumnPtr & col = arguments[0].column; const ColumnPtr & col = arguments[0].column;
if (arguments[0].type->onlyNull() && !col->empty())
throw Exception(ErrorCodes::ILLEGAL_COLUMN, "Cannot create non-empty column with type Nothing");
if (const auto * nullable_col = checkAndGetColumn<ColumnNullable>(*col)) if (const auto * nullable_col = checkAndGetColumn<ColumnNullable>(*col))
return nullable_col->getNestedColumnPtr(); return nullable_col->getNestedColumnPtr();
else else

View File

@ -39,8 +39,6 @@ public:
bool useDefaultImplementationForNulls() const override { return false; } bool useDefaultImplementationForNulls() const override { return false; }
bool useDefaultImplementationForNothing() const override { return false; }
bool isSuitableForConstantFolding() const override { return false; } bool isSuitableForConstantFolding() const override { return false; }
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; } bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }

View File

@ -65,6 +65,7 @@ public:
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return true; } bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return true; }
bool useDefaultImplementationForNulls() const override { return false; } bool useDefaultImplementationForNulls() const override { return false; }
/// map(..., Nothing) -> Map(..., Nothing)
bool useDefaultImplementationForNothing() const override { return false; } bool useDefaultImplementationForNothing() const override { return false; }
bool useDefaultImplementationForConstants() const override { return true; } bool useDefaultImplementationForConstants() const override { return true; }

View File

@ -23,11 +23,6 @@ public:
return false; return false;
} }
bool useDefaultImplementationForNothing() const override
{
return false;
}
/// Get the function name. /// Get the function name.
String getName() const override String getName() const override
{ {

View File

@ -52,6 +52,7 @@ public:
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; } bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }
bool useDefaultImplementationForNulls() const override { return false; } bool useDefaultImplementationForNulls() const override { return false; }
/// tuple(..., Nothing, ...) -> Tuple(..., Nothing, ...)
bool useDefaultImplementationForNothing() const override { return false; } bool useDefaultImplementationForNothing() const override { return false; }
bool useDefaultImplementationForConstants() const override { return true; } bool useDefaultImplementationForConstants() const override { return true; }

View File

@ -4,32 +4,26 @@ Array(Nothing)
Array(Nothing) Array(Nothing)
[] []
Array(Nothing) Array(Nothing)
Array(Nothing)
Array(Nothing)
[] []
Array(Nothing) Array(Nothing)
Array(String)
Array(Nothing) Array(Nothing)
Array(Nothing) Array(Nothing)
Array(Array(Nothing))
Nothing Array(Array(Nothing))
Const(Nothing) Array(Map(UInt8, Nothing))
Nothing Array(Map(UInt8, Nothing))
Const(Nothing) Array(Tuple(Nothing))
Array(Tuple(UInt8, Nothing))
Nothing
Nothing
Nothing Nothing
Nothing Nothing
Array(Nothing)
Const(Array(Nothing))
Array(Nothing) Array(Nothing)
Array(Nothing) Array(Nothing)
Map(UInt8, Nothing) Map(UInt8, Nothing)
Const(Map(UInt8, Nothing))
Map(UInt8, Nothing)
Map(UInt8, Nothing) Map(UInt8, Nothing)
Tuple(UInt8, Nothing) Tuple(UInt8, Nothing)
Const(Tuple(UInt8, Nothing))
Tuple(UInt8, Nothing)
Tuple(UInt8, Nothing) Tuple(UInt8, Nothing)
Nothing Nothing
Const(Nothing)
Nothing
Nothing Nothing

View File

@ -5,39 +5,36 @@ select toTypeName(arrayMap((x, y) -> x + y, [], []));
select arrayMap((x, y) -> x + y, [], CAST([], 'Array(Int32)')); select arrayMap((x, y) -> x + y, [], CAST([], 'Array(Int32)'));
select toTypeName(arrayMap((x, y) -> x + y, [], CAST([], 'Array(Int32)'))); select toTypeName(arrayMap((x, y) -> x + y, [], CAST([], 'Array(Int32)')));
select toTypeName(arrayMap(x -> 2 * x, [assumeNotNull(NULL)]));
select toColumnTypeName(arrayMap(x -> 2 * x, [assumeNotNull(NULL)]));
select arrayFilter(x -> 2 * x < 0, []); select arrayFilter(x -> 2 * x < 0, []);
select toTypeName(arrayFilter(x -> 2 * x < 0, [])); select toTypeName(arrayFilter(x -> 2 * x < 0, []));
select toTypeName(arrayFilter(x -> 2 * x < 0, [assumeNotNull(NULL)]));
select toColumnTypeName(arrayFilter(x -> 2 * x < 0, [assumeNotNull(NULL)]));
select CAST(assumeNotNull(NULL), 'String'); select toTypeName(arrayMap(x -> CAST(x, 'String'), []));
select toTypeName(toInt32(assumeNotNull(NULL))); select toTypeName(arrayMap(x -> toInt32(x), []));
select toColumnTypeName(toInt32(assumeNotNull(NULL))); select toColumnTypeName(arrayMap(x -> toInt32(x), []));
select toTypeName(arrayMap(x -> [x], []));
select toColumnTypeName(arrayMap(x -> [x], []));
select toTypeName(arrayMap(x ->map(1, x), []));
select toColumnTypeName(arrayMap(x -> map(1, x), []));
select toTypeName(arrayMap(x ->tuple(x), []));
select toColumnTypeName(arrayMap(x -> tuple(1, x), []));
select toTypeName(toInt32(assumeNotNull(materialize(NULL))));
select toColumnTypeName(toInt32(assumeNotNull(materialize(NULL))));
select toTypeName(assumeNotNull(NULL));
select toColumnTypeName(assumeNotNull(NULL));
select toTypeName(assumeNotNull(materialize(NULL))); select toTypeName(assumeNotNull(materialize(NULL)));
select toColumnTypeName(assumeNotNull(materialize(NULL))); select toColumnTypeName(assumeNotNull(materialize(NULL)));
select toTypeName([assumeNotNull(NULL)]);
select toColumnTypeName([assumeNotNull(NULL)]);
select toTypeName([assumeNotNull(materialize(NULL))]); select toTypeName([assumeNotNull(materialize(NULL))]);
select toColumnTypeName([assumeNotNull(materialize(NULL))]); select toColumnTypeName([assumeNotNull(materialize(NULL))]);
select toTypeName(map(1, assumeNotNull(NULL)));
select toColumnTypeName(map(1, assumeNotNull(NULL)));
select toTypeName(map(1, assumeNotNull(materialize(NULL)))); select toTypeName(map(1, assumeNotNull(materialize(NULL))));
select toColumnTypeName(map(1, assumeNotNull(materialize(NULL)))); select toColumnTypeName(map(1, assumeNotNull(materialize(NULL))));
select toTypeName(tuple(1, assumeNotNull(NULL)));
select toColumnTypeName(tuple(1, assumeNotNull(NULL)));
select toTypeName(tuple(1, assumeNotNull(materialize(NULL)))); select toTypeName(tuple(1, assumeNotNull(materialize(NULL))));
select toColumnTypeName(tuple(1, assumeNotNull(materialize(NULL)))); select toColumnTypeName(tuple(1, assumeNotNull(materialize(NULL))));
select toTypeName(assumeNotNull(NULL) * 2);
select toColumnTypeName(assumeNotNull(NULL) * 2);
select toTypeName(assumeNotNull(materialize(NULL)) * 2); select toTypeName(assumeNotNull(materialize(NULL)) * 2);
select toColumnTypeName(assumeNotNull(materialize(NULL)) * 2); select toColumnTypeName(assumeNotNull(materialize(NULL)) * 2);

View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CUR_DIR"/../shell_config.sh
$CLICKHOUSE_LOCAL -q "SELECT assumeNotNull(NULL)" 2>&1 | grep -q "ILLEGAL_COLUMN" && echo "OK" || echo "FAIL"
$CLICKHOUSE_LOCAL -q "SELECT assumeNotNull(materialize(NULL))" 2>&1 | grep -q "ILLEGAL_TYPE_OF_ARGUMENT" && echo "OK" || echo "FAIL"
$CLICKHOUSE_LOCAL -q "SELECT assumeNotNull(materialize(NULL)) from numbers(10)" 2>&1 | grep -q "ILLEGAL_TYPE_OF_ARGUMENT" && echo "OK" || echo "FAIL"