Skip to content

Commit

Permalink
Merge ad66fca into c0d8d34
Browse files Browse the repository at this point in the history
  • Loading branch information
ajantha-bhat committed Jul 22, 2019
2 parents c0d8d34 + ad66fca commit af3f1b9
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -698,11 +698,20 @@ class CarbonLateDecodeRule extends Rule[LogicalPlan] with PredicateHelper {
u
case p: Project if relations.nonEmpty =>
val prExps = p.projectList.map { prExp =>
var isSubstringPresent = false
prExp.transform {
case attr: AttributeReference =>
updateDataType(attr, attrMap, allAttrsNotDecode, aliasMap)
case subStr: Substring =>
isSubstringPresent = true
subStr
}
}.asInstanceOf[Seq[NamedExpression]]
if (!isSubstringPresent) {
prExp.transform {
case attr: AttributeReference =>
updateDataType(attr, attrMap, allAttrsNotDecode, aliasMap)
}
}
prExp
}
Project(prExps, p.child)
case wd: Window if relations.nonEmpty =>
val prExps = wd.output.map { prExp =>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.spark.carbondata.query

import org.apache.spark.sql.Row
import org.apache.spark.sql.common.util.Spark2QueryTest
import org.scalatest.BeforeAndAfterAll

class SubQueryJoinTestSuite extends Spark2QueryTest with BeforeAndAfterAll {

test("test to check if 2nd level subquery gives correct result") {
sql("drop table if exists t1")
sql("drop table if exists t2")

sql("create table t1 (s1 string) stored by 'carbondata' tblproperties('dictionary_include'='s1')")
sql("insert into t1 select 'abcd' ")
sql("insert into t1 select 'efgh' ")
sql("insert into t1 select 'ijkl' ")

sql("create table t2 (t2 string) stored by 'carbondata'")
sql("insert into t2 select 'ef' ")

checkAnswer(sql(
"select a.ch from (select substring(s1,1,2) as ch from t1) a join t2 h on (a.ch = h.t2)"),
Seq(Row("ef")))

sql("drop table t1")
sql("drop table t2")

}
}

0 comments on commit af3f1b9

Please sign in to comment.