use of io.crate.sql.tree.CreateSnapshot in project crate by crate.
the class CreateSnapshotAnalyzer method analyze.
public AnalyzedCreateSnapshot analyze(CreateSnapshot<Expression> createSnapshot, ParamTypeHints paramTypeHints, CoordinatorTxnCtx txnCtx) {
String repositoryName = createSnapshot.name().getPrefix().map(name -> {
validateRepository(name);
return name.toString();
}).orElseThrow(() -> new IllegalArgumentException("Snapshot must be specified by \"<repository_name>\".\"<snapshot_name>\""));
String snapshotName = createSnapshot.name().getSuffix();
Snapshot snapshot = new Snapshot(repositoryName, new SnapshotId(snapshotName, UUIDs.dirtyUUID().toString()));
var exprCtx = new ExpressionAnalysisContext(txnCtx.sessionContext());
var exprAnalyzerWithoutFields = new ExpressionAnalyzer(txnCtx, nodeCtx, paramTypeHints, FieldProvider.UNSUPPORTED, null);
var exprAnalyzerWithFieldsAsString = new ExpressionAnalyzer(txnCtx, nodeCtx, paramTypeHints, FieldProvider.FIELDS_AS_LITERAL, null);
List<Table<Symbol>> tables = Lists2.map(createSnapshot.tables(), (table) -> table.map(x -> exprAnalyzerWithFieldsAsString.convert(x, exprCtx)));
GenericProperties<Symbol> properties = createSnapshot.properties().map(x -> exprAnalyzerWithoutFields.convert(x, exprCtx));
return new AnalyzedCreateSnapshot(snapshot, tables, properties);
}
Aggregations