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';
報錯:mysql
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'aaa' in 'where clause'
測試發現:只要是字符串類型的過濾條件均報錯。git
詳見最新master分支的[Spark-6408]github
在測試sparksql操做phoenix時,因爲where條件中有字符串類型的值,就一直報錯一直報錯,後來用MySQL測試了下,發現也是相似的問題,跟蹤了源代碼發現是Filter出了問題。sql