apecloud / myduckserver

MySQL & Postgres Analytics, Reimagined
187 stars 9 forks source link

fix: int64 vs float64 mismatch in `SELECT floor(i)` #57

Open GaoYusong opened 2 months ago

GaoYusong commented 2 months ago
 --- FAIL: TestQueriesSimple/SELECT_floor(i),_s_FROM_mytable_mt_ORDER_BY_floor(i)_DESC (0.09s)
        /Users/shannon/code/myduckserver/evaluation.go:726: 
                Error Trace:    /Users/shannon/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/enginetest/evaluation.go:726
                                            /Users/shannon/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/enginetest/evaluation.go:357
                Error:          Not equal: 
                                expected: []sql.Row{sql.Row{3, "third row"}, sql.Row{2, "second row"}, sql.Row{1, "first row"}}
                                actual  : []sql.Row{sql.Row{3, "third row"}, sql.Row{2, "second row"}, sql.Row{1, "first row"}}

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -2,3 +2,3 @@
                                  (sql.Row) (len=2) {
                                -  (int64) 3,
                                +  (float64) 3,
                                   (string) (len=9) "third row"
                                @@ -6,3 +6,3 @@
                                  (sql.Row) (len=2) {
                                -  (int64) 2,
                                +  (float64) 2,
                                   (string) (len=10) "second row"
                                @@ -10,3 +10,3 @@
                                  (sql.Row) (len=2) {
                                -  (int64) 1,
                                +  (float64) 1,
                                   (string) (len=9) "first row"
                Test:           TestQueriesSimple/SELECT_floor(i),_s_FROM_mytable_mt_ORDER_BY_floor(i)_DESC
                Messages:       Unexpected result for query SELECT floor(i), s FROM mytable mt ORDER BY floor(i) DESC
GaoYusong commented 2 months ago

another return type mismatch issue

--- FAIL: TestQueriesSimple/SELECT_pk1,_SUM(c1)_FROM_two_pk_GROUP_BY_pk1_ORDER_BY_pk1; (0.04s)
        /Users/shannon/code/myduckserver/evaluation.go:726: 
                Error Trace:    /Users/shannon/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/enginetest/evaluation.go:726
                                            /Users/shannon/go/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/enginetest/evaluation.go:357
                Error:          Not equal: 
                                expected: []sql.Row{sql.Row{0, 10}, sql.Row{1, 50}}
                                actual  : []sql.Row{sql.Row{0, 10}, sql.Row{1, 50}}

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -3,3 +3,8 @@
                                   (int64) 0,
                                -  (float64) 10
                                +  (*big.Int)({
                                +   neg: (bool) false,
                                +   abs: (big.nat) (len=1) {
                                +    (big.Word) 10
                                +   }
                                +  })
                                  },
                                @@ -7,3 +12,8 @@
                                   (int64) 1,
                                -  (float64) 50
                                +  (*big.Int)({
                                +   neg: (bool) false,
                                +   abs: (big.nat) (len=1) {
                                +    (big.Word) 50
                                +   }
                                +  })
                                  }
                Test:           TestQueriesSimple/SELECT_pk1,_SUM(c1)_FROM_two_pk_GROUP_BY_pk1_ORDER_BY_pk1;
                Messages:       Unexpected result for query SELECT pk1, SUM(c1) FROM two_pk GROUP BY pk1 ORDER BY pk1
GaoYusong commented 2 months ago
--- FAIL: TestQueriesSimple (8.77s)
    --- FAIL: TestQueriesSimple/select_sum(10)_from_mytable (0.01s)
        /Users/ysg/code/myduckserver/evaluation.go:726: 
                Error Trace:    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/enginetest/evaluation.go:726
                                            /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/enginetest/evaluation.go:357
                Error:          Not equal: 
                                expected: []sql.Row{sql.Row{30}}
                                actual  : []sql.Row{sql.Row{30}}

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -2,3 +2,8 @@
                                  (sql.Row) (len=1) {
                                -  (float64) 30
                                +  (*big.Int)({
                                +   neg: (bool) false,
                                +   abs: (big.nat) (len=1) {
                                +    (big.Word) 30
                                +   }
                                +  })
                                  }
                Test:           TestQueriesSimple/select_sum(10)_from_mytable
                Messages:       Unexpected result for query select sum(10) from mytable
ddh-5230 commented 4 days ago

“DuckDB and MySQL’s SUM and FLOOR functions have different return rules for different types, as follows:” duckdb: sum(DECIMAL) -> DECIMAL sum(SMALLINT) -> HUGEINT sum(INTEGER) -> HUGEINT sum(BIGINT) -> HUGEINT sum(HUGEINT) -> HUGEINT sum(DOUBLE) -> DOUBLE floor(FLOAT) -> FLOAT floor(DOUBLE) -> DOUBLE floor(DECIMAL) -> DECIMAL

mysql: sum(integer/DECIMAL) -> DECIMAL sum(float/double) -> double floor() -> int

i have already changed hugeint to int64. may we need to make any other modifications, and is it acceptable to tolerate some incompatibilities?”

GaoYusong commented 4 days ago

“DuckDB and MySQL’s SUM and FLOOR functions have different return rules for different types, as follows:” duckdb: sum(DECIMAL) -> DECIMAL sum(SMALLINT) -> HUGEINT sum(INTEGER) -> HUGEINT sum(BIGINT) -> HUGEINT sum(HUGEINT) -> HUGEINT sum(DOUBLE) -> DOUBLE floor(FLOAT) -> FLOAT floor(DOUBLE) -> DOUBLE floor(DECIMAL) -> DECIMAL

mysql: sum(integer/DECIMAL) -> DECIMAL sum(float/double) -> double floor() -> int

i have already changed hugeint to int64. may we need to make any other modifications, and is it acceptable to tolerate some incompatibilities?”

welcome back!