Drop SQL's Session features (elastic/x-pack-elasticsearch#2639)
They don't work now and don't seem important enough to fix for the first release. Maybe not ever. Original commit: elastic/x-pack-elasticsearch@61e2b77e08
This commit is contained in:
parent
5f385d9155
commit
6be886edd8
|
@ -56,9 +56,6 @@ statement
|
|||
| (DESCRIBE | DESC) tableIdentifier #showColumns
|
||||
| SHOW FUNCTIONS (LIKE? pattern=STRING)? #showFunctions
|
||||
| SHOW SCHEMAS #showSchemas
|
||||
| SHOW SESSION (key=identifier | (LIKE? pattern=STRING) | ALL) #showSession
|
||||
| SET SESSION? key=identifier EQ? value=constant #sessionSet
|
||||
| RESET SESSION? (key=identifier | (LIKE? pattern=STRING) | ALL) #sessionReset
|
||||
;
|
||||
|
||||
query
|
||||
|
|
|
@ -8,23 +8,17 @@ package org.elasticsearch.xpack.sql.parser;
|
|||
import org.elasticsearch.common.Booleans;
|
||||
import org.elasticsearch.xpack.sql.parser.SqlBaseParser.DebugContext;
|
||||
import org.elasticsearch.xpack.sql.parser.SqlBaseParser.ExplainContext;
|
||||
import org.elasticsearch.xpack.sql.parser.SqlBaseParser.SessionResetContext;
|
||||
import org.elasticsearch.xpack.sql.parser.SqlBaseParser.SessionSetContext;
|
||||
import org.elasticsearch.xpack.sql.parser.SqlBaseParser.ShowColumnsContext;
|
||||
import org.elasticsearch.xpack.sql.parser.SqlBaseParser.ShowFunctionsContext;
|
||||
import org.elasticsearch.xpack.sql.parser.SqlBaseParser.ShowSchemasContext;
|
||||
import org.elasticsearch.xpack.sql.parser.SqlBaseParser.ShowSessionContext;
|
||||
import org.elasticsearch.xpack.sql.parser.SqlBaseParser.ShowTablesContext;
|
||||
import org.elasticsearch.xpack.sql.plan.TableIdentifier;
|
||||
import org.elasticsearch.xpack.sql.plan.logical.command.Command;
|
||||
import org.elasticsearch.xpack.sql.plan.logical.command.Debug;
|
||||
import org.elasticsearch.xpack.sql.plan.logical.command.Explain;
|
||||
import org.elasticsearch.xpack.sql.plan.logical.command.SessionReset;
|
||||
import org.elasticsearch.xpack.sql.plan.logical.command.SessionSet;
|
||||
import org.elasticsearch.xpack.sql.plan.logical.command.ShowColumns;
|
||||
import org.elasticsearch.xpack.sql.plan.logical.command.ShowFunctions;
|
||||
import org.elasticsearch.xpack.sql.plan.logical.command.ShowSchemas;
|
||||
import org.elasticsearch.xpack.sql.plan.logical.command.ShowSession;
|
||||
import org.elasticsearch.xpack.sql.plan.logical.command.ShowTables;
|
||||
import org.elasticsearch.xpack.sql.tree.Location;
|
||||
|
||||
|
@ -122,19 +116,4 @@ abstract class CommandBuilder extends LogicalPlanBuilder {
|
|||
TableIdentifier identifier = visitTableIdentifier(ctx.tableIdentifier());
|
||||
return new ShowColumns(source(ctx), identifier.index());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitShowSession(ShowSessionContext ctx) {
|
||||
return new ShowSession(source(ctx), visitIdentifier(ctx.key), text(ctx.pattern));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitSessionSet(SessionSetContext ctx) {
|
||||
return new SessionSet(source(ctx), visitIdentifier(ctx.key), text(ctx.value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitSessionReset(SessionResetContext ctx) {
|
||||
return new SessionReset(source(ctx), visitIdentifier(ctx.key), text(ctx.pattern));
|
||||
}
|
||||
}
|
|
@ -124,42 +124,6 @@ class SqlBaseBaseListener implements SqlBaseListener {
|
|||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitShowSchemas(SqlBaseParser.ShowSchemasContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterShowSession(SqlBaseParser.ShowSessionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitShowSession(SqlBaseParser.ShowSessionContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterSessionSet(SqlBaseParser.SessionSetContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitSessionSet(SqlBaseParser.SessionSetContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterSessionReset(SqlBaseParser.SessionResetContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitSessionReset(SqlBaseParser.SessionResetContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
|
|
@ -79,27 +79,6 @@ class SqlBaseBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements SqlBa
|
|||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitShowSchemas(SqlBaseParser.ShowSchemasContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitShowSession(SqlBaseParser.ShowSessionContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitSessionSet(SqlBaseParser.SessionSetContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitSessionReset(SqlBaseParser.SessionResetContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
|
|
@ -116,42 +116,6 @@ interface SqlBaseListener extends ParseTreeListener {
|
|||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitShowSchemas(SqlBaseParser.ShowSchemasContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by the {@code showSession}
|
||||
* labeled alternative in {@link SqlBaseParser#statement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterShowSession(SqlBaseParser.ShowSessionContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by the {@code showSession}
|
||||
* labeled alternative in {@link SqlBaseParser#statement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitShowSession(SqlBaseParser.ShowSessionContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by the {@code sessionSet}
|
||||
* labeled alternative in {@link SqlBaseParser#statement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterSessionSet(SqlBaseParser.SessionSetContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by the {@code sessionSet}
|
||||
* labeled alternative in {@link SqlBaseParser#statement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitSessionSet(SqlBaseParser.SessionSetContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by the {@code sessionReset}
|
||||
* labeled alternative in {@link SqlBaseParser#statement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterSessionReset(SqlBaseParser.SessionResetContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by the {@code sessionReset}
|
||||
* labeled alternative in {@link SqlBaseParser#statement}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitSessionReset(SqlBaseParser.SessionResetContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link SqlBaseParser#query}.
|
||||
* @param ctx the parse tree
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -76,27 +76,6 @@ interface SqlBaseVisitor<T> extends ParseTreeVisitor<T> {
|
|||
* @return the visitor result
|
||||
*/
|
||||
T visitShowSchemas(SqlBaseParser.ShowSchemasContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by the {@code showSession}
|
||||
* labeled alternative in {@link SqlBaseParser#statement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitShowSession(SqlBaseParser.ShowSessionContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by the {@code sessionSet}
|
||||
* labeled alternative in {@link SqlBaseParser#statement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitSessionSet(SqlBaseParser.SessionSetContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by the {@code sessionReset}
|
||||
* labeled alternative in {@link SqlBaseParser#statement}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitSessionReset(SqlBaseParser.SessionResetContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link SqlBaseParser#query}.
|
||||
* @param ctx the parse tree
|
||||
|
|
|
@ -1,95 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.sql.plan.logical.command;
|
||||
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.Settings.Builder;
|
||||
import org.elasticsearch.xpack.sql.expression.Attribute;
|
||||
import org.elasticsearch.xpack.sql.expression.RootFieldAttribute;
|
||||
import org.elasticsearch.xpack.sql.session.RowSet;
|
||||
import org.elasticsearch.xpack.sql.session.Rows;
|
||||
import org.elasticsearch.xpack.sql.session.SqlSession;
|
||||
import org.elasticsearch.xpack.sql.tree.Location;
|
||||
import org.elasticsearch.xpack.sql.type.DataTypes;
|
||||
import org.elasticsearch.xpack.sql.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
public class SessionReset extends Command {
|
||||
|
||||
private final String key, pattern;
|
||||
|
||||
public SessionReset(Location location, String key, String pattern) {
|
||||
super(location);
|
||||
this.key = key;
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public String key() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String pattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Attribute> output() {
|
||||
return asList(new RootFieldAttribute(location(), "key", DataTypes.KEYWORD),
|
||||
new RootFieldAttribute(location(), "value", DataTypes.KEYWORD));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RowSet execute(SqlSession session) {
|
||||
// NOCOMMIT this isn't likely to work any more. None of the session stuff is.
|
||||
session.updateSettings(s -> {
|
||||
Settings defaults = session.defaults().cfg();
|
||||
Builder builder = Settings.builder().put(s);
|
||||
if (pattern != null) {
|
||||
Pattern p = StringUtils.likeRegex(pattern);
|
||||
s.getAsMap().forEach((k, v) -> {
|
||||
if (p.matcher(k).matches()) {
|
||||
builder.put(k, defaults.get(k));
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
builder.put(key, defaults.get(key));
|
||||
}
|
||||
return builder.build();
|
||||
});
|
||||
|
||||
return Rows.of(output(), session.settings().cfg().getAsMap().entrySet().stream()
|
||||
.map(e -> asList(e.getKey(), e.getValue()))
|
||||
.collect(toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(key, pattern);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SessionReset other = (SessionReset) obj;
|
||||
return Objects.equals(key, other.key)
|
||||
&& Objects.equals(pattern, other.pattern) ;
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.sql.plan.logical.command;
|
||||
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.sql.expression.Attribute;
|
||||
import org.elasticsearch.xpack.sql.expression.RootFieldAttribute;
|
||||
import org.elasticsearch.xpack.sql.session.RowSet;
|
||||
import org.elasticsearch.xpack.sql.session.Rows;
|
||||
import org.elasticsearch.xpack.sql.session.SqlSession;
|
||||
import org.elasticsearch.xpack.sql.tree.Location;
|
||||
import org.elasticsearch.xpack.sql.type.DataTypes;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
|
||||
public class SessionSet extends Command {
|
||||
|
||||
private final String key, value;
|
||||
|
||||
public SessionSet(Location location, String key, String value) {
|
||||
super(location);
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String key() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Attribute> output() {
|
||||
return singletonList(new RootFieldAttribute(location(), "result", DataTypes.KEYWORD));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RowSet execute(SqlSession session) {
|
||||
session.updateSettings(s -> {
|
||||
return Settings.builder().put(s).put(key, value).build();
|
||||
});
|
||||
return Rows.empty(output());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(key, value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SessionSet other = (SessionSet) obj;
|
||||
return Objects.equals(key, other.key)
|
||||
&& Objects.equals(value, other.value) ;
|
||||
}
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
package org.elasticsearch.xpack.sql.plan.logical.command;
|
||||
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.sql.expression.Attribute;
|
||||
import org.elasticsearch.xpack.sql.expression.RootFieldAttribute;
|
||||
import org.elasticsearch.xpack.sql.session.RowSet;
|
||||
import org.elasticsearch.xpack.sql.session.Rows;
|
||||
import org.elasticsearch.xpack.sql.session.SqlSession;
|
||||
import org.elasticsearch.xpack.sql.tree.Location;
|
||||
import org.elasticsearch.xpack.sql.type.DataTypes;
|
||||
import org.elasticsearch.xpack.sql.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Collections.singletonList;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
public class ShowSession extends Command {
|
||||
|
||||
private final String key, pattern;
|
||||
|
||||
public ShowSession(Location location, String key, String pattern) {
|
||||
super(location);
|
||||
this.key = key;
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public String key() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String pattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Attribute> output() {
|
||||
return asList(new RootFieldAttribute(location(), "key", DataTypes.KEYWORD),
|
||||
new RootFieldAttribute(location(), "value", DataTypes.KEYWORD));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RowSet execute(SqlSession session) {
|
||||
List<List<?>> out;
|
||||
|
||||
Settings s = session.settings().cfg();
|
||||
|
||||
if (key != null) {
|
||||
out = singletonList(asList(key, s.get(key)));
|
||||
}
|
||||
else {
|
||||
if (pattern != null) {
|
||||
Pattern p = StringUtils.likeRegex(pattern);
|
||||
s = s.filter(k -> p.matcher(k).matches());
|
||||
}
|
||||
|
||||
out = s.getAsMap().entrySet().stream()
|
||||
.map(e -> asList(e.getKey(), e.getValue()))
|
||||
.collect(toList());
|
||||
}
|
||||
|
||||
return Rows.of(output(), out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(location());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -8,7 +8,6 @@ package org.elasticsearch.xpack.sql.session;
|
|||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.sql.analysis.analyzer.Analyzer;
|
||||
import org.elasticsearch.xpack.sql.analysis.catalog.Catalog;
|
||||
import org.elasticsearch.xpack.sql.analysis.catalog.EsIndex;
|
||||
|
@ -22,7 +21,6 @@ import org.elasticsearch.xpack.sql.planner.Planner;
|
|||
import org.elasticsearch.xpack.sql.plugin.SqlGetIndicesAction;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class SqlSession {
|
||||
|
||||
|
@ -34,10 +32,11 @@ public class SqlSession {
|
|||
private final Optimizer optimizer;
|
||||
private final Planner planner;
|
||||
|
||||
private final SqlSettings defaults;
|
||||
private final SqlSettings defaults; // NOCOMMIT this doesn't look used
|
||||
private SqlSettings settings;
|
||||
|
||||
// thread-local used for sharing settings across the plan compilation
|
||||
// TODO investigate removing
|
||||
public static final ThreadLocal<SqlSettings> CURRENT = new ThreadLocal<SqlSettings>() {
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -148,11 +147,6 @@ public class SqlSession {
|
|||
return settings;
|
||||
}
|
||||
|
||||
public SqlSettings updateSettings(Function<Settings, Settings> transformer) {
|
||||
settings = new SqlSettings(transformer.apply(settings.cfg()));
|
||||
return settings;
|
||||
}
|
||||
|
||||
public void execute(PhysicalPlan plan, ActionListener<RowSet> listener) {
|
||||
plan.execute(this, listener);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue