FAILED: SemanticException [Error 10016]: Line 66:45 Argument type mismatch ‘ca_coupon_id‘: “map“ or "list" is expected at function SIZE, but "string" is found

created at 09-08-2021 views: 12

error statement:

if(ca_coupon_id is null, 0, size(ca_coupon_id)) as m_coupon_available_num

Supplementary

The meaning of if(a, b, c) under MySQL is: if the value of the first expression is TRUE (not 0 or null), then return the value of the second parameter, otherwise return the third The value of each parameter.

reason

the data type in the size() function should be map or list, and ca_coupon_id is of type String, and the same problem remains behind.

solve

  • Method 1: Since the query code uses size multiple times and extracts the first element [0], here we redefine the data type (ca_coupon_id array <string>) and rebuild the table.
  • Method 2: Modify the method of obtaining the length directly, change size (ca_coupon_id) to length (ca_coupon_id), note that it is not len(), usually the length of the string can be obtained through len, but I am not feasible here, I don't know why.
created at:09-08-2021
edited at: 09-08-2021: