Skip to content

Commit

Permalink
#353 Register Denodo dialect via Denodo SQL generator when it is firs…
Browse files Browse the repository at this point in the history
…t used.
  • Loading branch information
yruslan committed Feb 15, 2024
1 parent cda8efb commit 705c1e6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,32 @@

package za.co.absa.pramen.core.sql

import org.apache.spark.sql.jdbc.JdbcDialects
import org.slf4j.LoggerFactory
import za.co.absa.pramen.api.sql.{SqlColumnType, SqlConfig, SqlGeneratorBase}
import za.co.absa.pramen.core.sql.dialects.DenodoDialect

import java.time.LocalDate
import java.time.format.DateTimeFormatter

object SqlGeneratorDenodo {
private val log = LoggerFactory.getLogger(this.getClass)

/**
* This is required for Spark to be able to handle data that comes from Denodo JDBC drivers
*/
lazy val registerDialect: Boolean = {
log.info(s"Registering Denodo dialect...")
JdbcDialects.registerDialect(DenodoDialect)
true
}
}

class SqlGeneratorDenodo(sqlConfig: SqlConfig) extends SqlGeneratorBase(sqlConfig) {
private val dateFormatterApp = DateTimeFormatter.ofPattern(sqlConfig.dateFormatApp)

SqlGeneratorDenodo.registerDialect

override val beginEndEscapeChars: (Char, Char) = ('\"', '\"')

override def getDtable(sql: String): String = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package za.co.absa.pramen.core.sql
import org.apache.spark.sql.jdbc.JdbcDialects
import org.slf4j.LoggerFactory
import za.co.absa.pramen.api.sql.{SqlColumnType, SqlConfig, SqlGeneratorBase}
import za.co.absa.pramen.core.sql.impl.HiveDialect
import za.co.absa.pramen.core.sql.dialects.HiveDialect

import java.time.LocalDate
import java.time.format.DateTimeFormatter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package za.co.absa.pramen.core.sql
import org.apache.spark.sql.jdbc.JdbcDialects
import org.slf4j.LoggerFactory
import za.co.absa.pramen.api.sql.{SqlColumnType, SqlConfig, SqlGeneratorBase}
import za.co.absa.pramen.core.sql.impl.SasDialect
import za.co.absa.pramen.core.sql.dialects.SasDialect

import java.sql.{Connection, ResultSet}
import java.time.LocalDate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package za.co.absa.pramen.core.sql.impl
package za.co.absa.pramen.core.sql.dialects

import org.apache.spark.sql.jdbc.JdbcDialect
import org.apache.spark.sql.types.{DataType, MetadataBuilder}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package za.co.absa.pramen.core.sql.impl
package za.co.absa.pramen.core.sql.dialects

import org.apache.spark.sql.jdbc.JdbcDialect
import org.apache.spark.sql.types.{DataType, MetadataBuilder}
Expand Down

0 comments on commit 705c1e6

Please sign in to comment.