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

[lambda]array_map(append_trailing_char_if_absent) function error in external table #12769

Closed
lvchenyang-maker opened this issue Nov 1, 2022 · 3 comments
Assignees
Labels
type/bug Something isn't working
Milestone

Comments

@lvchenyang-maker
Copy link

Steps to reproduce the behavior (Required)

  1. CREATE TABLE '...'
create external catalog hive_catalog_2e3394f0_59b2_11ed_91ff_00163e0e550b PROPERTIES("type" = "hive","hive.metastore.uris" = "thrift://ip:port");
  1. SELECT '....'
select col_int,array_map(x ->append_trailing_char_if_absent('', 'a'),col_array_string) from hive_catalog_d75112be_58f0_11ed_b73c_00163e0e550b.hive_extbl_test_arra

Expected behavior (Required)

['a']

Real behavior (Required)

['']
image

StarRocks version (Required)

  • You can get the StarRocks version by executing SQL select current_version()
+----------------------+
| current_version()    |
+----------------------+
| MAIN-RELEASE c1b178c |
+----------------------+
@lvchenyang-maker lvchenyang-maker added the type/bug Something isn't working label Nov 1, 2022
@lvchenyang-maker lvchenyang-maker added this to the 2.5.0 milestone Nov 1, 2022
@fzhedu
Copy link
Contributor

fzhedu commented Nov 8, 2022

Root cause:

SR cannot identify empty strings from hive, no matter with lambda function.

hive

hive> select * from s;
OK

NULL

abc
Time taken: 0.159 seconds, Fetched: 4 row(s)

hive> select count(*) from s where a = '';
OK
2
Time taken: 34.251 seconds, Fetched: 1 row(s)

SR

mysql> select count(*) from s;
+----------+
| count(*) |
+----------+
|        2 |
+----------+
1 row in set (0.12 sec)

mysql> select count(*) from s where a = '';
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (0.07 sec)

@zombee0
Copy link
Contributor

zombee0 commented Nov 15, 2022

the reason is that append_trailing_char_if_absent('', 'a') treat arg[0] as const column and add 'a' when the arg[0].length=0 while on the col is not constant, it check the length and skip the row that src_length=0

@fzhedu
Copy link
Contributor

fzhedu commented Nov 18, 2022

append_trailing_char_if_absent's behavior is different when the first arg is an empty string by from columns or not.

mysql> Create table t ( a int, name char(20), pv double) ENGINE=OLAP DUPLICATE KEY(a)  DISTRIBUTED BY HASH(a) BUCKETS 10 PROPERTIES("replication_num" = "1");
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t values (1,'',3);
Query OK, 1 row affected (0.03 sec)
{'label':'insert_a4e0c3d6-670e-11ed-b25b-00163e1f2aee', 'status':'VISIBLE', 'txnId':'5640284'}

mysql> select append_trailing_char_if_absent(name,'a') from t;
+-------------------------------------------+
| append_trailing_char_if_absent(name, 'a') |
+-------------------------------------------+
|                                           |
+-------------------------------------------+
1 row in set (0.01 sec)

mysql> select append_trailing_char_if_absent(name,'a') from t;
+-------------------------------------------+
| append_trailing_char_if_absent(name, 'a') |
+-------------------------------------------+
|                                           |
+-------------------------------------------+
1 row in set (0.00 sec)

mysql> select append_trailing_char_if_absent('','a') from t;
+-----------------------------------------+
| append_trailing_char_if_absent('', 'a') |
+-----------------------------------------+
| a                                       |
+-----------------------------------------+
1 row in set (0.00 sec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants