Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14116#discussion_r71834208
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/systemcatalog/InformationSchema.scala
 ---
    @@ -0,0 +1,312 @@
    +/*
    + * 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.systemcatalog
    +
    +import scala.collection.mutable.ArrayBuffer
    +
    +import org.apache.spark.rdd.RDD
    +import org.apache.spark.sql._
    +import 
org.apache.spark.sql.catalyst.catalog.SessionCatalog.{DEFAULT_DATABASE, 
INFORMATION_SCHEMA_DATABASE}
    +import org.apache.spark.sql.catalyst.dsl.plans._
    +import org.apache.spark.sql.catalyst.expressions._
    +import org.apache.spark.sql.catalyst.plans.logical.Project
    +import org.apache.spark.sql.execution.datasources._
    +import org.apache.spark.sql.internal.CatalogImpl
    +import org.apache.spark.sql.sources._
    +import org.apache.spark.sql.types._
    +
    +/**
    + * INFORMATION_SCHEMA is a database consisting views which provide 
information about all of the
    + * tables, views, columns in a database.
    + *
    + * These views are designed to be populated by this package in order to be 
independent from
    + * Spark catalog. To keep minimal dependency, currently INFORMATION_SCHEMA 
views are implemented as
    + * Spark temporary views with a database prefix: 
`SessionCatalog.INFORMATION_SCHEMA_DATABASE`.
    + *
    + * The following is the class hierarchy in this package rooted at 
InformationSchemaRelationProvider.
    + *
    + * InformationSchemaRelationProvider
    + *  -> DatabasesRelationProvider
    + *  -> TablesRelationProvider
    + *  -> ViewsRelationProvider
    + *  -> ColumnsRelationProvider
    + *  -> SessionVariablesRelationProvider
    + */
    +
    +/**
    + * InformationSchema object provides bootstrap and utility functions.
    + */
    +object InformationSchema {
    +
    +  /**
    +   * Register INFORMATION_SCHEMA database. SessionCatalog.catalog invokes 
this function.
    +   */
    +  def registerInformationSchema(sparkSession: SparkSession): Unit = {
    +    sparkSession.sql(s"CREATE DATABASE IF NOT EXISTS 
$INFORMATION_SCHEMA_DATABASE")
    +    registerView(sparkSession, new DatabasesRelationProvider, 
Seq("schemata", "databases"))
    +    registerView(sparkSession, new TablesRelationProvider, Seq("tables"))
    +    registerView(sparkSession, new ViewsRelationProvider, Seq("views"))
    +    registerView(sparkSession, new ColumnsRelationProvider, Seq("columns"))
    +    registerView(sparkSession, new SessionVariablesRelationProvider, 
Seq("session_variables"))
    +  }
    +
    +  /**
    +   * Register an INFORMATION_SCHEMA relation provider as a temporary view 
of Spark Catalog.
    +   */
    +  private def registerView(
    +      sparkSession: SparkSession,
    +      relationProvider: SchemaRelationProvider,
    +      names: Seq[String]) {
    +    val plan =
    +      
LogicalRelation(relationProvider.createRelation(sparkSession.sqlContext, null, 
null)).analyze
    --- End diff --
    
    Yep.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to