Search in sources :

Example 1 with Catalog

use of org.apache.spark.sql.catalog.Catalog in project jpmml-sparkml by jpmml.

the class DatasetUtil method createAnalyzedLogicalPlan.

public static LogicalPlan createAnalyzedLogicalPlan(SparkSession sparkSession, StructType schema, String statement) {
    String tableName = "sql2pmml_" + DatasetUtil.ID.getAndIncrement();
    statement = statement.replace("__THIS__", tableName);
    Dataset<Row> dataset = sparkSession.createDataFrame(Collections.emptyList(), schema);
    dataset.createOrReplaceTempView(tableName);
    try {
        QueryExecution queryExecution = sparkSession.sql(statement).queryExecution();
        return queryExecution.analyzed();
    } finally {
        Catalog catalog = sparkSession.catalog();
        catalog.dropTempView(tableName);
    }
}
Also used : Row(org.apache.spark.sql.Row) QueryExecution(org.apache.spark.sql.execution.QueryExecution) Catalog(org.apache.spark.sql.catalog.Catalog)

Aggregations

Row (org.apache.spark.sql.Row)1 Catalog (org.apache.spark.sql.catalog.Catalog)1 QueryExecution (org.apache.spark.sql.execution.QueryExecution)1