matrixorigin / matrixone

Hyperconverged cloud-edge native database
https://docs.matrixorigin.cn/en
Apache License 2.0
1.79k stars 276 forks source link

[Feature Request]: implement function ascii() #7281

Closed aressu1985 closed 1 year ago

aressu1985 commented 1 year ago

Is there an existing issue for the same feature request?

Is your feature request related to a problem?

in CHbenchMark Queries, Q5,Q7,Q8,Q10 need func ascii().

such as:
SELECT n_name, sum(ol_amount) AS revenue 
                    FROM customer, 
                    oorder, 
                    order_line, 
                    stock, 
                    supplier, 
                    nation, 
                    region 
                    WHERE c_id = o_c_id 
                    AND c_w_id = o_w_id 
                    AND c_d_id = o_d_id 
                    AND ol_o_id = o_id 
                    AND ol_w_id = o_w_id 
                    AND ol_d_id=o_d_id 
                    AND ol_w_id = s_w_id 
                    AND ol_i_id = s_i_id 
                    AND MOD((s_w_id * s_i_id), 10000) = su_suppkey 
                    AND ascii(substring(c_state from  1  for  1)) = su_nationkey 
                    AND su_nationkey = n_nationkey 
                    AND n_regionkey = r_regionkey 
                    AND r_name = 'Europe' 
                    AND o_entry_d >= '2007-01-02 00:00:00.000000' 
                    GROUP BY n_name 
                    ORDER BY revenue DESC

Describe the feature you'd like

Returns the numeric value of the leftmost character of the string str. Returns 0 if str is the empty string. Returns NULL if str is NULL. ASCII() works for 8-bit characters.

mysql> SELECT ASCII('2'); -> 50 mysql> SELECT ASCII(2); -> 50 mysql> SELECT ASCII('dx'); -> 100

Describe implementation you've considered

No response

Documentation, Adoption, Use Case, Migration Strategy

No response

Additional information

No response

daviszhen commented 1 year ago

mysql ascii function needed by the htap tools

aressu1985 commented 1 year ago

test done