Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Report: TPCH query fields incorrect in sharded environment #15643

Closed
GuptaManan100 opened this issue Apr 4, 2024 · 0 comments · Fixed by #15623
Closed

Bug Report: TPCH query fields incorrect in sharded environment #15643

GuptaManan100 opened this issue Apr 4, 2024 · 0 comments · Fixed by #15623

Comments

@GuptaManan100
Copy link
Member

Overview of the Issue

If we try and run the TPCH query set in a sharded setup, we see that the first query -

select
	l_returnflag,
	l_linestatus,
	sum(l_quantity) as sum_qty,
	sum(l_extendedprice) as sum_base_price,
	sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,
	sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,
	avg(l_quantity) as avg_qty,
	avg(l_extendedprice) as avg_price,
	avg(l_discount) as avg_disc,
	count(*) as count_order
from
	lineitem
where
	l_shipdate <= date_sub('1998-12-01', interval 108 day)
group by
	l_returnflag,
	l_linestatus
order by
	l_returnflag,
	l_linestatus;

gives back incorrect fields for a bunch of columns, wherein the precision of the decimal fields doesn't match what mysql gives us.

Reproduction Steps

Create a sharded cluster with the following vschema -

{
  "sharded": true,
  "foreignKeyMode": "unspecified",
  "vindexes": {
    "hash": {
      "type": "hash"
    }
  },
  "tables": {
    "basic": {
      "name": "basic",
      "column_vindexes": [
        {
          "columns": [
            "a"
          ],
          "type": "hash",
          "name": "hash"
        }
      ]
    },
    "customer": {
      "name": "customer",
      "column_vindexes": [
        {
          "columns": [
            "C_CUSTKEY"
          ],
          "type": "hash",
          "name": "hash"
        }
      ]
    },
    "lineitem": {
      "name": "lineitem",
      "column_vindexes": [
        {
          "columns": [
            "L_ORDERKEY",
            "L_LINENUMBER"
          ],
          "type": "hash",
          "name": "hash"
        }
      ]
    },
    "nation": {
      "name": "nation",
      "column_vindexes": [
        {
          "columns": [
            "N_NATIONKEY"
          ],
          "type": "hash",
          "name": "hash"
        }
      ]
    },
    "orders": {
      "name": "orders",
      "column_vindexes": [
        {
          "columns": [
            "O_ORDERKEY"
          ],
          "type": "hash",
          "name": "hash"
        }
      ]
    },
    "part": {
      "name": "part",
      "column_vindexes": [
        {
          "columns": [
            "P_PARTKEY"
          ],
          "type": "hash",
          "name": "hash"
        }
      ]
    },
    "partsupp": {
      "name": "partsupp",
      "column_vindexes": [
        {
          "columns": [
            "PS_PARTKEY",
            "PS_SUPPKEY"
          ],
          "type": "hash",
          "name": "hash"
        }
      ]
    },
    "region": {
      "name": "region",
      "column_vindexes": [
        {
          "columns": [
            "R_REGIONKEY"
          ],
          "type": "hash",
          "name": "hash"
        }
      ]
    },
    "supplier": {
      "name": "supplier",
      "column_vindexes": [
        {
          "columns": [
            "S_SUPPKEY"
          ],
          "type": "hash",
          "name": "hash"
        }
      ]
    }
  }
}

and the following schema -

CREATE TABLE IF NOT EXISTS nation
(
    N_NATIONKEY
    INTEGER
    NOT
    NULL,
    N_NAME
    CHAR
(
    25
) NOT NULL,
    N_REGIONKEY INTEGER NOT NULL,
    N_COMMENT VARCHAR
(
    152
),
    PRIMARY KEY
(
    N_NATIONKEY
));

CREATE TABLE IF NOT EXISTS region
(
    R_REGIONKEY
    INTEGER
    NOT
    NULL,
    R_NAME
    CHAR
(
    25
) NOT NULL,
    R_COMMENT VARCHAR
(
    152
),
    PRIMARY KEY
(
    R_REGIONKEY
));

CREATE TABLE IF NOT EXISTS part
(
    P_PARTKEY
    INTEGER
    NOT
    NULL,
    P_NAME
    VARCHAR
(
    55
) NOT NULL,
    P_MFGR CHAR
(
    25
) NOT NULL,
    P_BRAND CHAR
(
    10
) NOT NULL,
    P_TYPE VARCHAR
(
    25
) NOT NULL,
    P_SIZE INTEGER NOT NULL,
    P_CONTAINER CHAR
(
    10
) NOT NULL,
    P_RETAILPRICE DECIMAL
(
    15,
    2
) NOT NULL,
    P_COMMENT VARCHAR
(
    23
) NOT NULL,
    PRIMARY KEY
(
    P_PARTKEY
));

CREATE TABLE IF NOT EXISTS supplier
(
    S_SUPPKEY
    INTEGER
    NOT
    NULL,
    S_NAME
    CHAR
(
    25
) NOT NULL,
    S_ADDRESS VARCHAR
(
    40
) NOT NULL,
    S_NATIONKEY INTEGER NOT NULL,
    S_PHONE CHAR
(
    15
) NOT NULL,
    S_ACCTBAL DECIMAL
(
    15,
    2
) NOT NULL,
    S_COMMENT VARCHAR
(
    101
) NOT NULL,
    PRIMARY KEY
(
    S_SUPPKEY
));

CREATE TABLE IF NOT EXISTS partsupp
(
    PS_PARTKEY
    INTEGER
    NOT
    NULL,
    PS_SUPPKEY
    INTEGER
    NOT
    NULL,
    PS_AVAILQTY
    INTEGER
    NOT
    NULL,
    PS_SUPPLYCOST
    DECIMAL
(
    15,
    2
) NOT NULL,
    PS_COMMENT VARCHAR
(
    199
) NOT NULL,
    PRIMARY KEY
(
    PS_PARTKEY,
    PS_SUPPKEY
));

CREATE TABLE IF NOT EXISTS customer
(
    C_CUSTKEY
    INTEGER
    NOT
    NULL,
    C_NAME
    VARCHAR
(
    25
) NOT NULL,
    C_ADDRESS VARCHAR
(
    40
) NOT NULL,
    C_NATIONKEY INTEGER NOT NULL,
    C_PHONE CHAR
(
    15
) NOT NULL,
    C_ACCTBAL DECIMAL
(
    15,
    2
) NOT NULL,
    C_MKTSEGMENT CHAR
(
    10
) NOT NULL,
    C_COMMENT VARCHAR
(
    117
) NOT NULL,
    PRIMARY KEY
(
    C_CUSTKEY
));

CREATE TABLE IF NOT EXISTS orders
(
    O_ORDERKEY
    INTEGER
    NOT
    NULL,
    O_CUSTKEY
    INTEGER
    NOT
    NULL,
    O_ORDERSTATUS
    CHAR
(
    1
) NOT NULL,
    O_TOTALPRICE DECIMAL
(
    15,
    2
) NOT NULL,
    O_ORDERDATE DATE NOT NULL,
    O_ORDERPRIORITY CHAR
(
    15
) NOT NULL,
    O_CLERK CHAR
(
    15
) NOT NULL,
    O_SHIPPRIORITY INTEGER NOT NULL,
    O_COMMENT VARCHAR
(
    79
) NOT NULL,
    PRIMARY KEY
(
    O_ORDERKEY
));

CREATE TABLE IF NOT EXISTS lineitem
(
    L_ORDERKEY
    INTEGER
    NOT
    NULL,
    L_PARTKEY
    INTEGER
    NOT
    NULL,
    L_SUPPKEY
    INTEGER
    NOT
    NULL,
    L_LINENUMBER
    INTEGER
    NOT
    NULL,
    L_QUANTITY
    DECIMAL
(
    15,
    2
) NOT NULL,
    L_EXTENDEDPRICE DECIMAL
(
    15,
    2
) NOT NULL,
    L_DISCOUNT DECIMAL
(
    15,
    2
) NOT NULL,
    L_TAX DECIMAL
(
    15,
    2
) NOT NULL,
    L_RETURNFLAG CHAR
(
    1
) NOT NULL,
    L_LINESTATUS CHAR
(
    1
) NOT NULL,
    L_SHIPDATE DATE NOT NULL,
    L_COMMITDATE DATE NOT NULL,
    L_RECEIPTDATE DATE NOT NULL,
    L_SHIPINSTRUCT CHAR
(
    25
) NOT NULL,
    L_SHIPMODE CHAR
(
    10
) NOT NULL,
    L_COMMENT VARCHAR
(
    44
) NOT NULL,
    PRIMARY KEY
(
    L_ORDERKEY,
    L_LINENUMBER
));

Binary Version

main

Operating System and Environment details

-

Log Fragments

No response

@GuptaManan100 GuptaManan100 added Type: Bug Needs Triage This issue needs to be correctly labelled and triaged Component: Query Serving and removed Needs Triage This issue needs to be correctly labelled and triaged labels Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant