BigQuery标准SQL RPAD - LPAD不一致

时间:2017-06-26 08:32:46

标签: google-bigquery

RPAD似乎有问题,因为以下查询的响应为真:

SELECT LPAD(" hello world",7)= RPAD(" hello world",7);

JobId:custom-manifest-113615:bquijob_6cbc14f2_15ce386dbf3

1 个答案:

答案 0 :(得分:2)

我觉得这不是错误,并按预期返回结果

LPAD / RPAD(“hello world”,7) - 返回“hello world”的7个字符,因为那里有超过7个字符 - 它们只返回那些没有任何填充的字符。 “你好w”和“你好w”

要查看LPAD / RPAD的运行情况,请执行以下操作

  
#standardSQL
SELECT 
  LPAD("hello world", 17) as lpad, 
  RPAD("hello world", 17) as rpad, 
  LPAD("hello world", 17) = RPAD("hello world", 17) as compare    

#standardSQL
SELECT 
  LPAD("hello world", 17, ".") as lpad, 
  RPAD("hello world", 17, ".") as rpad, 
  LPAD("hello world", 17, ".") = RPAD("hello world", 17, ".") as compare  

从文档中For example, RPAD("hello world", 7); returns "o world".开始 - 我觉得这是不正确的! RightnessLeftness仅用于了解模式填充的方向!

注意:填充模式的默认值为blank space