Skip to content

Commit

Permalink
Merge ad66fca into d7d70a8
Browse files Browse the repository at this point in the history
  • Loading branch information
ajantha-bhat committed Aug 2, 2019
2 parents d7d70a8 + ad66fca commit 97937f1
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 3 deletions.
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
@@ -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 97937f1

Please sign in to comment.