taiyang-li opened a new issue, #6016:
URL: https://github.com/apache/incubator-gluten/issues/6016

   ### Backend
   
   CH (ClickHouse)
   
   ### Bug description
   
   In CH
   ```
   select cast(3005820000 as Decimal(29, 2)) as x, x::Int32   
   Received exception from server (version 24.4.1):
   Code: 407. DB::Exception: Received from localhost:9001. DB::Exception: 
Convert overflow: In scope SELECT CAST(3005820000, 'Decimal(29, 2)') AS x, 
CAST(x, 'Int32'). Stack trace:
   
   0. Poco::Exception::Exception(String const&, int) @ 0x00000000115f495d
   1. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 
0x0000000009c1dbff
   2. DB::Exception::Exception<>(int, FormatStringHelperImpl<>) @ 
0x0000000004ef4cca
   3. void DB::DecimalUtils::convertToImpl<int, 
DB::Decimal<wide::integer<128ul, int>>, void>(DB::Decimal<wide::integer<128ul, 
int>> const&, unsigned int, int&) @ 0x000000000d928acc
   4. 
_ZN2DB18convertFromDecimalINS_15DataTypeDecimalINS_7DecimalIN4wide7integerILm128EiEEEEEENS_14DataTypeNumberIiEEQaa17IsDataTypeDecimalIT_E15is_arithmetic_vINT0_9FieldTypeEEEESC_RKNSA_9FieldTypeEj
 @ 0x000000000d92b531
   5. bool DB::callOnIndexAndDataType<DB::DataTypeNumber<int>, DB::(anonymous 
namespace)::FunctionConvert<DB::DataTypeNumber<int>, DB::(anonymous 
namespace)::NameToInt32, DB::(anonymous 
namespace)::ToNumberMonotonicity<int>>::executeInternal(std::vector<DB::ColumnWithTypeAndName,
 std::allocator<DB::ColumnWithTypeAndName>> const&, 
std::shared_ptr<DB::IDataType const> const&, unsigned long) 
const::'lambda'(auto const&, DB::(anonymous 
namespace)::BehaviourOnErrorFromString)&, DB::(anonymous 
namespace)::BehaviourOnErrorFromString>(DB::TypeIndex, DB::(anonymous 
namespace)::FunctionConvert<DB::DataTypeNumber<int>, DB::(anonymous 
namespace)::NameToInt32, DB::(anonymous 
namespace)::ToNumberMonotonicity<int>>::executeInternal(std::vector<DB::ColumnWithTypeAndName,
 std::allocator<DB::ColumnWithTypeAndName>> const&, 
std::shared_ptr<DB::IDataType const> const&, unsigned long) 
const::'lambda'(auto const&, DB::(anonymous 
namespace)::BehaviourOnErrorFromString)&, DB::(anonymous namespace)::Behaviou
 rOnErrorFromString&&) @ 0x0000000005034f7f
   6. DB::(anonymous namespace)::FunctionConvert<DB::DataTypeNumber<int>, 
DB::(anonymous namespace)::NameToInt32, DB::(anonymous 
namespace)::ToNumberMonotonicity<int>>::executeImpl(std::vector<DB::ColumnWithTypeAndName,
 std::allocator<DB::ColumnWithTypeAndName>> const&, 
std::shared_ptr<DB::IDataType const> const&, unsigned long) const @ 
0x0000000005030aae
   7. 
DB::FunctionToExecutableFunctionAdaptor::executeImpl(std::vector<DB::ColumnWithTypeAndName,
 std::allocator<DB::ColumnWithTypeAndName>> const&, 
std::shared_ptr<DB::IDataType const> const&, unsigned long) const @ 
0x000000000520bc73
   8. 
DB::IExecutableFunction::executeWithoutLowCardinalityColumns(std::vector<DB::ColumnWithTypeAndName,
 std::allocator<DB::ColumnWithTypeAndName>> const&, 
std::shared_ptr<DB::IDataType const> const&, unsigned long, bool) const @ 
0x000000000d32b4c6
   9. 
DB::IExecutableFunction::executeWithoutSparseColumns(std::vector<DB::ColumnWithTypeAndName,
 std::allocator<DB::ColumnWithTypeAndName>> const&, 
std::shared_ptr<DB::IDataType const> const&, unsigned long, bool) const @ 
0x000000000d32be2d
   10. DB::IExecutableFunction::execute(std::vector<DB::ColumnWithTypeAndName, 
std::allocator<DB::ColumnWithTypeAndName>> const&, 
std::shared_ptr<DB::IDataType const> const&, unsigned long, bool) const @ 
0x000000000d32d08c
   11. DB::IFunctionBase::execute(std::vector<DB::ColumnWithTypeAndName, 
std::allocator<DB::ColumnWithTypeAndName>> const&, 
std::shared_ptr<DB::IDataType const> const&, unsigned long, bool) const @ 
0x0000000004f0418b
   12. COW<DB::IColumn>::immutable_ptr<DB::IColumn> 
std::__function::__policy_invoker<COW<DB::IColumn>::immutable_ptr<DB::IColumn> 
(std::vector<DB::ColumnWithTypeAndName, 
std::allocator<DB::ColumnWithTypeAndName>>&, std::shared_ptr<DB::IDataType 
const> const&, DB::ColumnNullable const*, unsigned 
long)>::__call_impl<std::__function::__default_alloc_func<DB::(anonymous 
namespace)::FunctionCast::createFunctionAdaptor(std::shared_ptr<DB::IFunction>, 
std::shared_ptr<DB::IDataType const> 
const&)::'lambda'(std::vector<DB::ColumnWithTypeAndName, 
std::allocator<DB::ColumnWithTypeAndName>>&, std::shared_ptr<DB::IDataType 
const> const&, DB::ColumnNullable const*, unsigned long), 
COW<DB::IColumn>::immutable_ptr<DB::IColumn> 
(std::vector<DB::ColumnWithTypeAndName, 
std::allocator<DB::ColumnWithTypeAndName>>&, std::shared_ptr<DB::IDataType 
const> const&, DB::ColumnNullable const*, unsigned 
long)>>(std::__function::__policy_storage const*, 
std::vector<DB::ColumnWithTypeAndName, std::allocator<DB::Co
 lumnWithTypeAndName>>&, std::shared_ptr<DB::IDataType const> const&, 
DB::ColumnNullable const*, unsigned long) @ 0x0000000004fc67bb
   13. DB::(anonymous 
namespace)::ExecutableFunctionCast::executeImpl(std::vector<DB::ColumnWithTypeAndName,
 std::allocator<DB::ColumnWithTypeAndName>> const&, 
std::shared_ptr<DB::IDataType const> const&, unsigned long) const @ 
0x0000000004fb0e53
   14. 
DB::IExecutableFunction::executeDryRunImpl(std::vector<DB::ColumnWithTypeAndName,
 std::allocator<DB::ColumnWithTypeAndName>> const&, 
std::shared_ptr<DB::IDataType const> const&, unsigned long) const @ 
0x0000000004f0488f
   15. 
DB::IExecutableFunction::executeWithoutLowCardinalityColumns(std::vector<DB::ColumnWithTypeAndName,
 std::allocator<DB::ColumnWithTypeAndName>> const&, 
std::shared_ptr<DB::IDataType const> const&, unsigned long, bool) const @ 
0x000000000d32b4ae
   16. 
DB::IExecutableFunction::defaultImplementationForConstantArguments(std::vector<DB::ColumnWithTypeAndName,
 std::allocator<DB::ColumnWithTypeAndName>> const&, 
std::shared_ptr<DB::IDataType const> const&, unsigned long, bool) const @ 
0x000000000d32b070
   17. 
DB::IExecutableFunction::executeWithoutLowCardinalityColumns(std::vector<DB::ColumnWithTypeAndName,
 std::allocator<DB::ColumnWithTypeAndName>> const&, 
std::shared_ptr<DB::IDataType const> const&, unsigned long, bool) const @ 
0x000000000d32b455
   18. 
DB::IExecutableFunction::executeWithoutSparseColumns(std::vector<DB::ColumnWithTypeAndName,
 std::allocator<DB::ColumnWithTypeAndName>> const&, 
std::shared_ptr<DB::IDataType const> const&, unsigned long, bool) const @ 
0x000000000d32be99
   19. DB::IExecutableFunction::execute(std::vector<DB::ColumnWithTypeAndName, 
std::allocator<DB::ColumnWithTypeAndName>> const&, 
std::shared_ptr<DB::IDataType const> const&, unsigned long, bool) const @ 
0x000000000d32d08c
   20. DB::(anonymous 
namespace)::QueryAnalyzer::resolveFunction(std::shared_ptr<DB::IQueryTreeNode>&,
 DB::(anonymous namespace)::IdentifierResolveScope&) @ 0x000000000e25f868
   21. DB::(anonymous 
namespace)::QueryAnalyzer::resolveExpressionNode(std::shared_ptr<DB::IQueryTreeNode>&,
 DB::(anonymous namespace)::IdentifierResolveScope&, bool, bool) @ 
0x000000000e24c046
   22. DB::(anonymous 
namespace)::QueryAnalyzer::resolveExpressionNodeList(std::shared_ptr<DB::IQueryTreeNode>&,
 DB::(anonymous namespace)::IdentifierResolveScope&, bool, bool) @ 
0x000000000e24b494
   23. DB::(anonymous 
namespace)::QueryAnalyzer::resolveProjectionExpressionNodeList(std::shared_ptr<DB::IQueryTreeNode>&,
 DB::(anonymous namespace)::IdentifierResolveScope&) @ 0x000000000e252489
   24. DB::(anonymous 
namespace)::QueryAnalyzer::resolveQuery(std::shared_ptr<DB::IQueryTreeNode> 
const&, DB::(anonymous namespace)::IdentifierResolveScope&) @ 0x000000000e245057
   25. DB::QueryAnalysisPass::run(std::shared_ptr<DB::IQueryTreeNode>&, 
std::shared_ptr<DB::Context const>) @ 0x000000000e242f6d
   26. DB::QueryTreePassManager::run(std::shared_ptr<DB::IQueryTreeNode>) @ 
0x000000000e24145d
   27. DB::(anonymous 
namespace)::buildQueryTreeAndRunPasses(std::shared_ptr<DB::IAST> const&, 
DB::SelectQueryOptions const&, std::shared_ptr<DB::Context const> const&, 
std::shared_ptr<DB::IStorage> const&) @ 0x000000000e4d05f8
   28. 
DB::InterpreterSelectQueryAnalyzer::InterpreterSelectQueryAnalyzer(std::shared_ptr<DB::IAST>
 const&, std::shared_ptr<DB::Context const> const&, DB::SelectQueryOptions 
const&) @ 0x000000000e4cf0b4
   29. std::unique_ptr<DB::IInterpreter, std::default_delete<DB::IInterpreter>> 
std::__function::__policy_invoker<std::unique_ptr<DB::IInterpreter, 
std::default_delete<DB::IInterpreter>> (DB::InterpreterFactory::Arguments 
const&)>::__call_impl<std::__function::__default_alloc_func<DB::registerInterpreterSelectQueryAnalyzer(DB::InterpreterFactory&)::$_0,
 std::unique_ptr<DB::IInterpreter, std::default_delete<DB::IInterpreter>> 
(DB::InterpreterFactory::Arguments const&)>>(std::__function::__policy_storage 
const*, DB::InterpreterFactory::Arguments const&) @ 0x000000000e4d12b1
   30. DB::InterpreterFactory::get(std::shared_ptr<DB::IAST>&, 
std::shared_ptr<DB::Context>, DB::SelectQueryOptions const&) @ 
0x000000000e470ba5
   31. DB::executeQueryImpl(char const*, char const*, 
std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum, 
DB::ReadBuffer*) @ 0x000000000e8327e3
   . (DECIMAL_OVERFLOW)
   ``` 
   
   
   In Spark
   ```
   select int(cast(3005820000 as Decimal(29, 2)) )
   +------------------------------------+
   | CAST(3005820000 AS DECIMAL(29,2))  |
   +------------------------------------+
   | -1289147296                        |
   +------------------------------------+
   1 row selected (0.192 seconds)
   ```
   
   ### Spark version
   
   None
   
   ### Spark configurations
   
   _No response_
   
   ### System information
   
   _No response_
   
   ### Relevant logs
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to