我一直以为在 pig
中 ''
和 ""
是一样的,但今天我发现了它们的不同之处。
Unexpected character '"'
错误发生在
register datafu-pig-1.2.1.jar
define Coalesce datafu.pig.util.Coalesce;
...
Coalesce(x,"a")
while
Coalesce(x,'a')
这个很好用。
那么,单引号和双引号有什么区别呢?
我一直以为在 pig
中 ''
和 ""
是一样的,但今天我发现了它们的不同之处。
Unexpected character '"'
错误发生在
register datafu-pig-1.2.1.jar
define Coalesce datafu.pig.util.Coalesce;
...
Coalesce(x,"a")
while
Coalesce(x,'a')
这个很好用。
那么,单引号和双引号有什么区别呢?
Pig不支持双引号作为字符串字面量(即chararray)。所有的chararray必须用单引号括起来。
A String or Chararrays are represented in interfaces by java.lang.String.
Constant chararrays are expressed as string literals with single quotes, for example, 'fred'
Reference:http://chimera.labs.oreilly.com/books/1234000001811/ch04.html#scalar_types
chararray
。 - sds