Skip to content

[Bug] The Bug of Decimal or union #27841

Closed

Description

@Wilson-BT

Search before asking

  • I had searched in the issues and found no similar issues.

Version

selectdb-2.0.3

What's Wrong?

This a sql. and the column sal_amt_o2o 、sal_amt_offline... is the type of decimal(20,4)

SELECT *
		FROM (
			SELECT SUM(sal_amt_o2o + sal_amt_offline + sal_amt_sy_a + sal_amt_sy_b + sal_amt_dy + double_sy_b_sal_amt) AS monthSalAmtYj
			FROM dasuan_analysis_data.ads_org_sal_inv_kpi_d
			WHERE organ_new_no = 'NKBJBK'
				AND period_sdate BETWEEN '2023-11-30' AND '2023-11-30'
			UNION
			SELECT SUM(sal_amt_o2o + sal_amt_offline + sal_amt_sy_a + sal_amt_sy_b + sal_amt_dy + double_sy_b_sal_amt) AS monthSalAmtYj
			FROM dasuan_analysis_data.ads_org_sal_kpi_rt
			WHERE organ_new_no = 'NKBJBK'
				AND period_sdate = '2023-11-30'
		) a

when i execute the whole sql . the error will report

SQL 错误 [1105] [HY000]: errCode = 2, detailMessage = (10.250.168.39)[NOT_IMPLEMENTED_ERROR]Create Expr failed because [E3] Wrong precision 43, min: 1, max: 38

	0#  doris::Exception::Exception(int, std::basic_string_view<char, std::char_traits<char> >) at /usr/local/software/ldb_toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/unique_ptr.h:173
	1#  doris::Exception::Exception<unsigned long&, unsigned long, unsigned long>(int, std::basic_string_view<char, std::char_traits<char> >, unsigned long&, unsigned long&&, unsigned long&&) at /usr/local/software/ldb_toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/basic_string.h:187
	2#  doris::vectorized::create_decimal(unsigned long, unsigned long, bool) at /mnt/ssd01/selectdb-doris-package/enterprise-core/be/src/vec/data_types/data_type_decimal.cpp:0
	3#  doris::vectorized::DataTypeFactory::create_data_type(doris::TypeDescriptor const&, bool) at /mnt/ssd01/selectdb-doris-package/enterprise-core/be/src/vec/data_types/data_type_factory.cpp:0
	4#  doris::vectorized::VExpr::VExpr(doris::TExprNode const&) at /usr/local/software/ldb_toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/shared_ptr_base.h:1157
	5#  doris::vectorized::VSlotRef::VSlotRef(doris::TExprNode const&) at /mnt/ssd01/selectdb-doris-package/enterprise-core/be/src/vec/exprs/vslot_ref.cpp:41
	6#  doris::vectorized::VExpr::create_expr(doris::TExprNode const&, std::shared_ptr<doris::vectorized::VExpr>&) at /usr/local/software/ldb_toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_construct.h:0
	7#  doris::vectorized::VExpr::create_tree_from_thrift(std::vector<doris::TExprNode, std::allocator<doris::TExprNode> > const&, int*, std::shared_ptr<doris::vectorized::VExpr>&, std::shared_ptr<doris::vectorized::VExprContext>&) at /mnt/ssd01/selectdb-doris-package/

But when i Execute the small sql before each union separately ,such as

SELECT SUM(sal_amt_o2o + sal_amt_offline + sal_amt_sy_a + sal_amt_sy_b + sal_amt_dy + double_sy_b_sal_amt) AS monthSalAmtYj
			FROM dasuan_analysis_data.ads_org_sal_kpi_rt
			WHERE organ_new_no = 'NKBJBK'
				AND period_sdate = '2023-11-30'

or when i add cast as on column

SELECT *
		FROM (
			SELECT cast(SUM(sal_amt_o2o + sal_amt_offline + sal_amt_sy_a + sal_amt_sy_b + sal_amt_dy + double_sy_b_sal_amt) as double) AS monthSalAmtYj
			FROM dasuan_analysis_data.ads_org_sal_inv_kpi_d
			WHERE organ_new_no = 'NKBJBK'
				AND period_sdate = '2023-11-29' group by organ_new_no,period_sdate
			UNION 
			SELECT cast(SUM(sal_amt_o2o + sal_amt_offline + sal_amt_sy_a + sal_amt_sy_b + sal_amt_dy + double_sy_b_sal_amt) as double) AS monthSalAmtYj
			FROM dasuan_analysis_data.ads_org_sal_kpi_rt
			WHERE organ_new_no = 'NKBJBK'
				AND period_sdate = '2023-11-30' group by organ_new_no,period_sdate
		) a

it will return the right result.

!Important

And then. I rebuild this two tables, insert into new select * from old. and rerun the whole sql, it Passed!

So,i think,it`s decimal compatibility issues between different doris versions.

What You Expected?

i think it should return the right result.

How to Reproduce?

No response

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. changed the title [-][Bug] The Bug of Decimal[/-] [+][Bug] The Bug of Decimal or union[/+] on Nov 30, 2023
  2. LemonLiTree commented on Dec 1, 2023

    @LemonLiTree
    Contributor

    Which version did you upgrade from?

  3. Wilson-BT commented on Dec 1, 2023

    @Wilson-BT
    ContributorAuthor

    Which version did you upgrade from?

    1.1.5 ---> 1.2.6 ---> 2.0.3-rc4. The table had never changed. Column type is always decimal(20,4).

  4. github-actions commented on Sep 13, 2025

    @github-actions
    Contributor

    We're closing this issue because it hasn't been updated in a while.
    If you'd like to revive this issue, please reopen it and feel free a maintainer to remove the Stale tag!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions