Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-2339

SQL parser in sql-core is case sensitive, but a table alias is converted to lower case when we create Subquery

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.0.0
    • 1.0.2, 1.1.0
    • SQL
    • None

    Description

      Reported by http://apache-spark-user-list.1001560.n3.nabble.com/Spark-SQL-Join-throws-exception-td8599.html

      After we get the table from the catalog, because the table has an alias, we will temporarily insert a Subquery. Then, we convert the table alias to lower case no matter if the parser is case sensitive or not.

      To see the issue ...

      val sqlContext = new org.apache.spark.sql.SQLContext(sc)
      import sqlContext.createSchemaRDD
      
      case class Person(name: String, age: Int)
      
      val people = sc.textFile("examples/src/main/resources/people.txt").map(_.split(",")).map(p => Person(p(0), p(1).trim.toInt))
      people.registerAsTable("people")
      
      sqlContext.sql("select PEOPLE.name from people PEOPLE")
      

      The plan is ...

      == Query Plan ==
      Project ['PEOPLE.name]
       ExistingRdd [name#0,age#1], MapPartitionsRDD[4] at mapPartitions at basicOperators.scala:176
      

      You can find that "PEOPLE.name" is not resolved.

      Attachments

        Issue Links

          Activity

            People

              yhuai Yin Huai
              yhuai Yin Huai
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: