Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
address comments.
  • Loading branch information
gatorsmile committed Nov 17, 2016
commit bc9a5082cf4576cfa7a6d4911db74bc0476c4360
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,18 @@ object ExternalCatalogUtils {
}
}
}

object CatalogUtils {
/**
* Masking credentials in the option lists. For example, in the sql plan explain output
* for JDBC data sources.
*/
def maskCredentials(options: Map[String, String]): Map[String, String] = {
options.map {
case (key, _) if key.toLowerCase == "password" => (key, "###")
case (key, value) if key.toLowerCase == "url" && value.toLowerCase.contains("password") =>
(key, "###")
case o => o
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,10 @@ case class CatalogStorageFormat(
properties: Map[String, String]) {

override def toString: String = {
val maskedProperties = properties.map {
case (password, _) if password.toLowerCase == "password" => (password, "###")
case (url, value) if url.toLowerCase == "url" && value.toLowerCase.contains("password") =>
(url, "###")
case o => o
val serdePropsToString = CatalogUtils.maskCredentials(properties) match {
case props if props.isEmpty => ""
case props => s"Properties: " + props.map(p => p._1 + "=" + p._2).mkString("[", ", ", "]")
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: string interpolation not needed.

}
val serdePropsToString =
if (maskedProperties.nonEmpty) {
s"Properties: " + maskedProperties.map(p => p._1 + "=" + p._2).mkString("[", ", ", "]")
} else {
""
}
val output =
Seq(locationUri.map("Location: " + _).getOrElse(""),
inputFormat.map("InputFormat: " + _).getOrElse(""),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -767,16 +767,4 @@ object DDLUtils {
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: ?

/**
* Masking credentials in the option lists. For example, in the sql plan explain output
* for JDBC data sources.
*/
def maskCredentials(options: Map[String, String]): Map[String, String] = {
options.map {
case (password, _) if password.toLowerCase == "password" => (password, "###")
case (url, value) if url.toLowerCase == "url" && value.toLowerCase.contains("password") =>
(url, "###")
case o => o
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ case class DescribeTableCommand(
describeBucketingInfo(metadata, buffer)

append(buffer, "Storage Desc Parameters:", "", "")
val maskedProperties = DDLUtils.maskCredentials(metadata.storage.properties)
val maskedProperties = CatalogUtils.maskCredentials(metadata.storage.properties)
maskedProperties.foreach { case (key, value) =>
append(buffer, s" $key", value, "")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ package org.apache.spark.sql.execution.datasources

import org.apache.spark.sql._
import org.apache.spark.sql.catalyst.TableIdentifier
import org.apache.spark.sql.catalyst.catalog.CatalogTable
import org.apache.spark.sql.catalyst.catalog.{CatalogTable, CatalogUtils}
import org.apache.spark.sql.catalyst.plans.QueryPlan
import org.apache.spark.sql.catalyst.plans.logical.{Command, LogicalPlan}
import org.apache.spark.sql.execution.command.{DDLUtils, RunnableCommand}
import org.apache.spark.sql.execution.command.RunnableCommand
import org.apache.spark.sql.types._

case class CreateTable(
Expand Down Expand Up @@ -61,7 +61,7 @@ case class CreateTempViewUsing(
userSpecifiedSchema.getOrElse("") +
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need a space?

Copy link
Member Author

@gatorsmile gatorsmile Nov 25, 2016

Choose a reason for hiding this comment

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

Yeah. Thanks! It needs a space:

ExecutedCommand
   +- CreateTempViewUsing [tableIdent:`jsonTable` StructType(StructField(a,IntegerType,true), StructField(b,StringType,true))replace:true provider:org.apache.spark.sql.json.DefaultSource Map(path -> /private/var/folders/4b/sgmfldk15js406vk7lw5llzw0000gn/T/spark-88202701-92c6-44f2-9945-7f388551729b)

s"replace:$replace " +
s"provider:$provider " +
DDLUtils.maskCredentials(options)
CatalogUtils.maskCredentials(options)
}

def run(sparkSession: SparkSession): Seq[Row] = {
Expand Down