Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class TestBigDecimal extends QueryTest with BeforeAndAfterAll {
sql("create table if not exists hiveTable(ID Int, date Timestamp, country String, name String, phonetype String, serialname String, salary Decimal(17,2))row format delimited fields terminated by ','")
sql(s"LOAD DATA LOCAL INPATH '$resourcesPath/decimalDataWithHeader.csv' into table carbonTable")
sql(s"LOAD DATA local inpath '$resourcesPath/decimalDataWithoutHeader.csv' INTO table hiveTable")
sql("create table if not exists hiveBigDecimal(ID Int, date Timestamp, country String, name String, phonetype String, serialname String, salary decimal(27, 10))row format delimited fields terminated by ','")
sql("create table if not exists hiveBigDecimal(ID Int, date Timestamp, country String, name String, phonetype String, serialname String, salary decimal(30, 10))row format delimited fields terminated by ','")
sql(s"LOAD DATA local inpath '$resourcesPath/decimalBoundaryDataHive.csv' INTO table hiveBigDecimal")
sql("create table if not exists carbonBigDecimal_2 (ID Int, date Timestamp, country String, name String, phonetype String, serialname String, salary decimal(30, 10)) STORED BY 'org.apache.carbondata.format'")
sql(s"LOAD DATA LOCAL INPATH '$resourcesPath/decimalBoundaryDataCarbon.csv' into table carbonBigDecimal_2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,11 @@ object CarbonReflectionUtils {
.getMethod("writeAndRead",
classOf[SaveMode],
classOf[LogicalPlan],
classOf[Seq[Attribute]],
classOf[Seq[String]],
classOf[SparkPlan])
method.invoke(dataSourceObj, mode, query, query.output, physicalPlan)
// since spark 2.3.2 version (SPARK-PR#22346),
// change 'query.output' to 'query.output.map(_.name)'
method.invoke(dataSourceObj, mode, query, query.output.map(_.name), physicalPlan)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameters of 'writeAndRead' method had been changed, please see: SPARK-PR#22346

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added some comments too

.asInstanceOf[BaseRelation]
} else {
throw new UnsupportedOperationException("Spark version not supported")
Expand Down
2 changes: 1 addition & 1 deletion integration/spark-datasource/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@
<profile>
<id>spark-2.3</id>
<properties>
<spark.version>2.3.1</spark.version>
<spark.version>2.3.2</spark.version>
<scala.binary.version>2.11</scala.binary.version>
<scala.version>2.11.8</scala.version>
</properties>
Expand Down
5 changes: 4 additions & 1 deletion integration/spark2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
<configuration>
<sources>
<source>src/main/spark2.1</source>
<source>src/main/commonTo2.1And2.2</source>
</sources>
</configuration>
</execution>
Expand Down Expand Up @@ -328,6 +329,7 @@
<sources>
<source>src/main/spark2.2</source>
<source>src/main/commonTo2.2And2.3</source>
<source>src/main/commonTo2.1And2.2</source>
</sources>
</configuration>
</execution>
Expand All @@ -339,7 +341,7 @@
<profile>
<id>spark-2.3</id>
<properties>
<spark.version>2.3.1</spark.version>
<spark.version>2.3.2</spark.version>
<scala.binary.version>2.11</scala.binary.version>
<scala.version>2.11.8</scala.version>
</properties>
Expand All @@ -352,6 +354,7 @@
<excludes>
<exclude>src/main/spark2.1</exclude>
<exclude>src/main/spark2.2</exclude>
<exclude>src/main/commonTo2.1And2.2</exclude>
</excludes>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why need to move CarbonDataSourceScan.scala?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move original class 'CarbonDataSourceScan' to src path 'commonTo2.1And2.2', and add a new class 'CarbonDataSourceScan' in src path 'spark2.3' which is added some lazy parameters.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comment : only for 4 parameters , copy the whole file(CarbonDataSourceScan.scala) for spark 2.3 integration, may not require. see if can add the judgement for different spark version with different code/parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chenliang613 , it's not about the different code/parameters, it changes common val parameters to lazy val parameters. I think it's difficult to add lazy keyword on val parameters according to spark version.
Or does anyone know how to do and give me some help, thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.

* 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.sql.execution.strategy

import org.apache.spark.rdd.RDD
import org.apache.spark.sql.catalyst.{InternalRow, TableIdentifier}
import org.apache.spark.sql.catalyst.expressions.{Attribute, SortOrder}
import org.apache.spark.sql.catalyst.plans.physical.Partitioning
import org.apache.spark.sql.execution.FileSourceScanExec
import org.apache.spark.sql.execution.datasources.{HadoopFsRelation, LogicalRelation}

/**
* Physical plan node for scanning data. It is applied for both tables
* USING carbondata and STORED AS CARBONDATA.
*/
class CarbonDataSourceScan(
override val output: Seq[Attribute],
val rdd: RDD[InternalRow],
@transient override val relation: HadoopFsRelation,
val partitioning: Partitioning,
val md: Map[String, String],
identifier: Option[TableIdentifier],
@transient private val logicalRelation: LogicalRelation)
extends FileSourceScanExec(
relation,
output,
relation.dataSchema,
Seq.empty,
Seq.empty,
identifier) {

// added lazy since spark 2.3.2 version (SPARK-PR#21815)
override lazy val supportsBatch: Boolean = true

// added lazy since spark 2.3.2 version (SPARK-PR#21815)
override lazy val (outputPartitioning, outputOrdering): (Partitioning, Seq[SortOrder]) =
(partitioning, Nil)

// added lazy since spark 2.3.2 version (SPARK-PR#21815)
override lazy val metadata: Map[String, String] = md
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameters (supportsBatch, outputPartitioning, outputOrdering, metadata) had been added keyword 'lazy', please see: SPARK-PR#21815

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: made lazy since spark 2.3.2 version (SPARK-PR#21815)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


override def inputRDDs(): Seq[RDD[InternalRow]] = rdd :: Nil

}
4 changes: 3 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@
<sourceDirectory>${basedir}/integration/spark2/src/main/scala</sourceDirectory>
<sourceDirectory>${basedir}/integration/spark2/src/main/java</sourceDirectory>
<sourceDirectory>${basedir}/integration/spark2/src/main/spark2.1</sourceDirectory>
<sourceDirectory>${basedir}/integration/spark2/src/main/commonTo2.1And2.2</sourceDirectory>
<sourceDirectory>${basedir}/integration/spark-common/src/main/scala</sourceDirectory>
<sourceDirectory>${basedir}/integration/spark-common/src/main/java</sourceDirectory>
<sourceDirectory>${basedir}/integration/spark-common-test/src/main/scala</sourceDirectory>
Expand Down Expand Up @@ -582,6 +583,7 @@
<sourceDirectory>${basedir}/hadoop/src/main/java</sourceDirectory>
<sourceDirectory>${basedir}/integration/spark2/src/main/scala</sourceDirectory>
<sourceDirectory>${basedir}/integration/spark2/src/main/spark2.2</sourceDirectory>
<sourceDirectory>${basedir}/integration/spark2/src/main/commonTo2.1And2.2</sourceDirectory>
<sourceDirectory>${basedir}/integration/spark2/src/main/commonTo2.2And2.3</sourceDirectory>
<sourceDirectory>${basedir}/integration/spark2/src/main/java</sourceDirectory>
<sourceDirectory>${basedir}/integration/spark-common/src/main/scala</sourceDirectory>
Expand All @@ -608,7 +610,7 @@
<profile>
<id>spark-2.3</id>
<properties>
<spark.version>2.3.1</spark.version>
<spark.version>2.3.2</spark.version>
<scala.binary.version>2.11</scala.binary.version>
<scala.version>2.11.8</scala.version>
</properties>
Expand Down