forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SC-5599] Inline spark-redshift sources into databricks/spark
This patch ports `spark-redshift` as of databricks/spark-avro@b01a034 and updates it to run with Spark 2.1.0. I didn't make any attempts to clean up the library, remove dead code, or modernize its dependencies. Each of these tasks will take some time and I'm hoping to delegate them out once we have the infrastructure pieces in place. Credentials are stored securely in Jenkins. If you need a copy of them to do local development, talk to Josh and he'll share them via ZeroBin (this will be done via LastPass in the future). Author: Josh Rosen <[email protected]> Closes apache#171 from JoshRosen/add-spark-redshift.
- Loading branch information
Showing
54 changed files
with
6,128 additions
and
6 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
common/tags/src/test/java/org/apache/spark/tags/ExtendedRedshiftTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright (C) 2016 Databricks, Inc. | ||
* | ||
* Portions of this software incorporate or are derived from software contained within Apache Spark, | ||
* and this modified software differs from the Apache Spark software provided under the Apache | ||
* License, Version 2.0, a copy of which you may obtain at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
package org.apache.spark.tags; | ||
|
||
import java.lang.annotation.*; | ||
|
||
import org.scalatest.TagAnnotation; | ||
|
||
@TagAnnotation | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.METHOD, ElementType.TYPE}) | ||
public @interface ExtendedRedshiftTest { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" | ||
SPARK_ROOT_DIR="$(dirname "$SCRIPT_DIR")" | ||
|
||
cd /tmp | ||
|
||
VERSION='1.1.7.1007' | ||
FILENAME="RedshiftJDBC4-$VERSION.jar" | ||
|
||
wget "https://s3.amazonaws.com/redshift-downloads/drivers/$FILENAME" | ||
|
||
$SPARK_ROOT_DIR/build/mvn install:install-file \ | ||
-Dfile=$FILENAME \ | ||
-DgroupId=com.amazonaws \ | ||
-DartifactId=redshift.jdbc4 \ | ||
-Dversion=$VERSION \ | ||
-Dpackaging=jar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/* | ||
* Copyright (C) 2016 Databricks, Inc. | ||
* | ||
* Portions of this software incorporate or are derived from software contained within Apache Spark, | ||
* and this modified software differs from the Apache Spark software provided under the Apache | ||
* License, Version 2.0, a copy of which you may obtain at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.apache.spark</groupId> | ||
<artifactId>spark-parent_2.11</artifactId> | ||
<version>2.1.0</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<groupId>com.databricks</groupId> | ||
<artifactId>spark-redshift-integration-tests_2.11</artifactId> | ||
<properties> | ||
<sbt.project.name>redshift-integration-tests</sbt.project.name> | ||
</properties> | ||
<packaging>jar</packaging> | ||
<name>Spark Redshift Integration Tests</name> | ||
<url>http://spark.apache.org/</url> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.spark</groupId> | ||
<artifactId>spark-sql_${scala.binary.version}</artifactId> | ||
<version>${project.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.databricks</groupId> | ||
<artifactId>spark-avro_${scala.binary.version}</artifactId> | ||
<version>${project.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.databricks</groupId> | ||
<artifactId>spark-redshift_${scala.binary.version}</artifactId> | ||
<version>${project.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.databricks</groupId> | ||
<artifactId>spark-redshift_${scala.binary.version}</artifactId> | ||
<version>${project.version}</version> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
<!-- The AWS Java SDK version here should match (or be below) the version used in DBC images --> | ||
<dependency> | ||
<groupId>com.amazonaws</groupId> | ||
<artifactId>aws-java-sdk-core</artifactId> | ||
<version>1.9.40</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.amazonaws</groupId> | ||
<artifactId>aws-java-sdk-s3</artifactId> | ||
<version>1.9.40</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.amazonaws</groupId> | ||
<artifactId>aws-java-sdk-sts</artifactId> | ||
<version>1.9.40</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.eclipsesource.minimal-json</groupId> | ||
<artifactId>minimal-json</artifactId> | ||
<version>0.9.4</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.hadoop</groupId> | ||
<artifactId>hadoop-client</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.hadoop</groupId> | ||
<artifactId>hadoop-common</artifactId> | ||
<version>${hadoop.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.spark</groupId> | ||
<artifactId>spark-core_${scala.binary.version}</artifactId> | ||
<version>${project.version}</version> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.spark</groupId> | ||
<artifactId>spark-catalyst_${scala.binary.version}</artifactId> | ||
<version>${project.version}</version> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.spark</groupId> | ||
<artifactId>spark-sql_${scala.binary.version}</artifactId> | ||
<version>${project.version}</version> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.spark</groupId> | ||
<artifactId>spark-hive_${scala.binary.version}</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<!-- This dependency is installed using ./dev/install-redshift-jdbc.sh --> | ||
<dependency> | ||
<groupId>com.amazonaws</groupId> | ||
<artifactId>redshift.jdbc4</artifactId> | ||
<version>1.1.7.1007</version> | ||
<type>jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.spark</groupId> | ||
<artifactId>spark-tags_${scala.binary.version}</artifactId> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<outputDirectory>target/scala-${scala.binary.version}/classes</outputDirectory> | ||
<testOutputDirectory>target/scala-${scala.binary.version}/test-classes</testOutputDirectory> | ||
</build> | ||
</project> |
52 changes: 52 additions & 0 deletions
52
...ts/src/test/scala/com/databricks/spark/redshift/AWSCredentialsInUriIntegrationSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (C) 2016 Databricks, Inc. | ||
* | ||
* Portions of this software incorporate or are derived from software contained within Apache Spark, | ||
* and this modified software differs from the Apache Spark software provided under the Apache | ||
* License, Version 2.0, a copy of which you may obtain at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
package com.databricks.spark.redshift | ||
|
||
import java.net.URI | ||
|
||
import org.apache.spark.SparkContext | ||
import org.apache.spark.sql.Row | ||
import org.apache.spark.sql.types.{IntegerType, StructField, StructType} | ||
import org.apache.spark.tags.ExtendedRedshiftTest | ||
|
||
/** | ||
* This suite performs basic integration tests where the AWS credentials have been | ||
* encoded into the tempdir URI rather than being set in the Hadoop configuration. | ||
*/ | ||
@ExtendedRedshiftTest | ||
class AWSCredentialsInUriIntegrationSuite extends IntegrationSuiteBase { | ||
|
||
override protected val tempDir: String = { | ||
val uri = new URI(AWS_S3_SCRATCH_SPACE + randomSuffix + "/") | ||
new URI( | ||
uri.getScheme, | ||
s"$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY", | ||
uri.getHost, | ||
uri.getPort, | ||
uri.getPath, | ||
uri.getQuery, | ||
uri.getFragment).toString | ||
} | ||
|
||
|
||
// Override this method so that we do not set the credentials in sc.hadoopConf. | ||
override def beforeAll(): Unit = { | ||
assert(tempDir.contains("AKIA"), "tempdir did not contain AWS credentials") | ||
assert(!AWS_SECRET_ACCESS_KEY.contains("/"), "AWS secret key should not contain slash") | ||
sc = new SparkContext("local", getClass.getSimpleName) | ||
conn = DefaultJDBCWrapper.getConnector(None, jdbcUrl, None) | ||
} | ||
|
||
test("roundtrip save and load") { | ||
val df = sqlContext.createDataFrame(sc.parallelize(Seq(Row(1)), 1), | ||
StructType(StructField("foo", IntegerType) :: Nil)) | ||
testRoundtripSaveAndLoad(s"roundtrip_save_and_load_$randomSuffix", df) | ||
} | ||
} |
Oops, something went wrong.