CREATE TEMPORARY TABLE spark_tbls USING org.apache.spark.sql.jdbc OPTIONS ( url 'jdbc:mysql://hadoop000:3306/hive?user=root&password=root', dbtable 'TBLS' );
select TBL_ID, TBL_NAME from spark_tbls limit 5; TBL_ID TBL_NAME 126 aaa 96 abc
select TBL_ID, TBL_NAME from spark_tbls where TBL_ID=126; TBL_ID TBL_NAME 126 aaa
select TBL_ID, TBL_NAME from spark_tbls where TBL_NAME='aaa';
报错:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'aaa' in 'where clause'
测试发现:只要是字符串类型的过滤条件均报错。
详见最新master分支的[Spark-6408]
在测试sparksql操作phoenix时,由于where条件中有字符串类型的值,就一直报错一直报错,后来用MySQL测试了下,发现也是类似的问题,跟踪了源代码发现是Filter出了问题。