From 6d6e2d77b032f2deaa4f44ea1589135a4745e959 Mon Sep 17 00:00:00 2001 From: radford1 Date: Wed, 12 Jul 2017 06:14:02 +0000 Subject: [PATCH 1/2] Added apache drill jdbc dialect --- .../spark/sql/jdbc/ApacheDrillDialect.scala | 31 +++++++++++++++++++ .../apache/spark/sql/jdbc/JdbcDialects.scala | 1 + 2 files changed, 32 insertions(+) create mode 100644 sql/core/src/main/scala/org/apache/spark/sql/jdbc/ApacheDrillDialect.scala diff --git a/sql/core/src/main/scala/org/apache/spark/sql/jdbc/ApacheDrillDialect.scala b/sql/core/src/main/scala/org/apache/spark/sql/jdbc/ApacheDrillDialect.scala new file mode 100644 index 000000000000..c9bbfb3a791b --- /dev/null +++ b/sql/core/src/main/scala/org/apache/spark/sql/jdbc/ApacheDrillDialect.scala @@ -0,0 +1,31 @@ +/* + * 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.jdbc + +import java.sql.Types + +import org.apache.spark.sql.types.{BooleanType, DataType, LongType, MetadataBuilder} + +private case object ApacheDrillDialect extends JdbcDialect { + + override def canHandle(url : String): Boolean = url.startsWith("jdbc:drill") + + override def quoteIdentifier(colName: String): String = { + s"`$colName`" + } +} diff --git a/sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala b/sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala index 7c38ed68c041..a47eec2201a3 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala @@ -200,6 +200,7 @@ object JdbcDialects { registerDialect(DerbyDialect) registerDialect(OracleDialect) registerDialect(TeradataDialect) + registerDialect(ApacheDrillDialect) /** * Fetch the JdbcDialect class corresponding to a given database url. From 15b867dbbca7e44b3cedbb3d0d936ca0df8b0d16 Mon Sep 17 00:00:00 2001 From: radford1 Date: Tue, 25 Jul 2017 10:51:08 -0500 Subject: [PATCH 2/2] Removed unused imports --- .../scala/org/apache/spark/sql/jdbc/ApacheDrillDialect.scala | 3 --- 1 file changed, 3 deletions(-) diff --git a/sql/core/src/main/scala/org/apache/spark/sql/jdbc/ApacheDrillDialect.scala b/sql/core/src/main/scala/org/apache/spark/sql/jdbc/ApacheDrillDialect.scala index c9bbfb3a791b..12b7b37c5161 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/jdbc/ApacheDrillDialect.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/jdbc/ApacheDrillDialect.scala @@ -17,9 +17,6 @@ package org.apache.spark.sql.jdbc -import java.sql.Types - -import org.apache.spark.sql.types.{BooleanType, DataType, LongType, MetadataBuilder} private case object ApacheDrillDialect extends JdbcDialect {