File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed
tests/integration/test_storage_postgresql Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -199,16 +199,12 @@ QueryTreeNodePtr ConstantNode::cloneImpl() const
199199
200200ASTPtr ConstantNode::toASTImpl (const ConvertToASTOptions & options) const
201201{
202+ if (!options.add_cast_for_constants )
203+ return std::make_shared<ASTLiteral>(getFieldFromColumnForASTLiteral (constant_value.getColumn (), 0 , constant_value.getType ()));
204+
202205 const auto & constant_value_type = constant_value.getType ();
203206 auto constant_value_ast = std::make_shared<ASTLiteral>(getValue ());
204207
205- if (!options.add_cast_for_constants )
206- {
207- if (WhichDataType (constant_value_type->getTypeId ()).isDateTimeOrDateTime64 ())
208- return std::make_shared<ASTLiteral>(getFieldFromColumnForASTLiteral (constant_value.getColumn (), 0 , constant_value.getType ()));
209- return constant_value_ast;
210- }
211-
212208 // Add cast if constant was created as a result of constant folding.
213209 // Constant folding may lead to type transformation and literal on shard
214210 // may have a different type.
Original file line number Diff line number Diff line change @@ -885,6 +885,12 @@ def test_postgres_datetime(started_cluster):
885885 result = node1 .query ("SELECT ts FROM test_datetime WHERE ts > '2025-01-01'::DateTime64" )
886886 assert result == "2025-01-02 03:04:05.678900\n "
887887
888+ result = node1 .query ("SELECT ts FROM test_datetime WHERE ts > '2025-01-01'::Nullable(DateTime)" )
889+ assert result == "2025-01-02 03:04:05.678900\n "
890+
891+ result = node1 .query ("SELECT ts FROM test_datetime WHERE ts > '2025-01-01'::Nullable(DateTime64)" )
892+ assert result == "2025-01-02 03:04:05.678900\n "
893+
888894
889895if __name__ == "__main__" :
890896 cluster .start ()
You can’t perform that action at this time.
0 commit comments