diff --git a/dbms/src/DataTypes/DataTypeMyDate.h b/dbms/src/DataTypes/DataTypeMyDate.h index 2a67fce1d77..2c85f0e4a9e 100644 --- a/dbms/src/DataTypes/DataTypeMyDate.h +++ b/dbms/src/DataTypes/DataTypeMyDate.h @@ -24,7 +24,6 @@ class DataTypeMyDate final : public DataTypeMyTimeBase void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const override; bool canBeUsedAsVersion() const override { return true; } - bool isDateOrDateTime() const override { return true; } bool canBeInsideNullable() const override { return true; } bool equals(const IDataType & rhs) const override; diff --git a/dbms/src/DataTypes/DataTypeMyTimeBase.h b/dbms/src/DataTypes/DataTypeMyTimeBase.h index 51bac428a62..df07cca0cf6 100644 --- a/dbms/src/DataTypes/DataTypeMyTimeBase.h +++ b/dbms/src/DataTypes/DataTypeMyTimeBase.h @@ -12,6 +12,7 @@ class DataTypeMyTimeBase : public DataTypeNumberBase public: bool canBeUsedAsVersion() const override { return true; } bool isDateOrDateTime() const override { return true; } + bool isMyDateOrMyDateTime() const override { return true; } bool canBeInsideNullable() const override { return true; } }; diff --git a/dbms/src/DataTypes/IDataType.h b/dbms/src/DataTypes/IDataType.h index 726e5a90208..570bab62d7c 100644 --- a/dbms/src/DataTypes/IDataType.h +++ b/dbms/src/DataTypes/IDataType.h @@ -345,6 +345,10 @@ class IDataType : private boost::noncopyable */ virtual bool isDateOrDateTime() const { return false; }; + /** MyDate, MyDateTime. Not Nullable. + */ + virtual bool isMyDateOrMyDateTime() const { return false; }; + /** Decimal. Not Nullable. */ virtual bool isDecimal() const { return false; }; diff --git a/dbms/src/Functions/FunctionsDateTime.h b/dbms/src/Functions/FunctionsDateTime.h index 9167d6f9bd2..1d9a9e20da6 100644 --- a/dbms/src/Functions/FunctionsDateTime.h +++ b/dbms/src/Functions/FunctionsDateTime.h @@ -2384,12 +2384,12 @@ class FunctionExtractMyDateTime : public IFunction // TODO: Support Extract from string, see https://github.com/pingcap/tidb/issues/22700 // if (!(arguments[1]->isString() || arguments[1]->isDateOrDateTime())) - if (!arguments[1]->isDateOrDateTime()) + if (!arguments[1]->isMyDateOrMyDateTime()) throw TiFlashException( "Illegal type " + arguments[1]->getName() + " of second argument of function " + getName() + ". Must be DateOrDateTime.", Errors::Coprocessor::BadRequest); - return std::make_shared(std::make_shared()); + return std::make_shared(); } bool useDefaultImplementationForConstants() const override { return true; } @@ -2406,13 +2406,6 @@ class FunctionExtractMyDateTime : public IFunction auto from_column = block.getByPosition(arguments[1]).column; - - if (from_column->onlyNull()) - { - block.getByPosition(result).column = block.getByPosition(result).type->createColumnConst(block.rows(), Null()); - return; - } - size_t rows = block.rows(); auto col_to = ColumnInt64::create(rows); auto & vec_to = col_to->getData();