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);
}
}
Aggregations