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:
Nik Everett 2017-09-28 13:41:58 -04:00 committed by GitHub
parent 5f385d9155
commit 6be886edd8
13 changed files with 964 additions and 1623 deletions

View File

@ -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

View File

@ -1,203 +1,203 @@
T__0=1
T__1=2
T__2=3
T__3=4
SELECT=5
FROM=6
AS=7
ALL=8
WHEN=9
THEN=10
ANY=11
DISTINCT=12
WHERE=13
GROUP=14
BY=15
GROUPING=16
SETS=17
ORDER=18
HAVING=19
LIMIT=20
OR=21
AND=22
IN=23
NOT=24
NO=25
EXISTS=26
BETWEEN=27
LIKE=28
RLIKE=29
IS=30
NULL=31
TRUE=32
FALSE=33
LAST=34
ASC=35
DESC=36
FOR=37
INTEGER=38
JOIN=39
CROSS=40
OUTER=41
INNER=42
LEFT=43
RIGHT=44
FULL=45
NATURAL=46
USING=47
ON=48
WITH=49
TABLE=50
INTO=51
DESCRIBE=52
OPTION=53
EXPLAIN=54
ANALYZE=55
FORMAT=56
TYPE=57
TEXT=58
VERIFY=59
GRAPHVIZ=60
LOGICAL=61
PHYSICAL=62
SHOW=63
TABLES=64
COLUMNS=65
COLUMN=66
FUNCTIONS=67
TO=68
DEBUG=69
PLAN=70
PARSED=71
ANALYZED=72
OPTIMIZED=73
MAPPED=74
EXECUTABLE=75
USE=76
SET=77
RESET=78
SESSION=79
SCHEMAS=80
EXTRACT=81
QUERY=82
MATCH=83
CAST=84
EQ=85
NEQ=86
LT=87
LTE=88
GT=89
GTE=90
PLUS=91
MINUS=92
ASTERISK=93
SLASH=94
PERCENT=95
CONCAT=96
STRING=97
INTEGER_VALUE=98
DECIMAL_VALUE=99
IDENTIFIER=100
DIGIT_IDENTIFIER=101
QUOTED_IDENTIFIER=102
BACKQUOTED_IDENTIFIER=103
SIMPLE_COMMENT=104
BRACKETED_COMMENT=105
WS=106
UNRECOGNIZED=107
DELIMITER=108
'('=1
')'=2
','=3
'.'=4
'SELECT'=5
'FROM'=6
'AS'=7
'ALL'=8
'WHEN'=9
'THEN'=10
'ANY'=11
'DISTINCT'=12
'WHERE'=13
'GROUP'=14
'BY'=15
'GROUPING'=16
'SETS'=17
'ORDER'=18
'HAVING'=19
'LIMIT'=20
'OR'=21
'AND'=22
'IN'=23
'NOT'=24
'NO'=25
'EXISTS'=26
'BETWEEN'=27
'LIKE'=28
'RLIKE'=29
'IS'=30
'NULL'=31
'TRUE'=32
'FALSE'=33
'LAST'=34
'ASC'=35
'DESC'=36
'FOR'=37
'INTEGER'=38
'JOIN'=39
'CROSS'=40
'OUTER'=41
'INNER'=42
'LEFT'=43
'RIGHT'=44
'FULL'=45
'NATURAL'=46
'USING'=47
'ON'=48
'WITH'=49
'TABLE'=50
'INTO'=51
'DESCRIBE'=52
'OPTION'=53
'EXPLAIN'=54
'ANALYZE'=55
'FORMAT'=56
'TYPE'=57
'TEXT'=58
'VERIFY'=59
'GRAPHVIZ'=60
'LOGICAL'=61
'PHYSICAL'=62
'SHOW'=63
'TABLES'=64
'COLUMNS'=65
'COLUMN'=66
'FUNCTIONS'=67
'TO'=68
'DEBUG'=69
'PLAN'=70
'PARSED'=71
'ANALYZED'=72
'OPTIMIZED'=73
'MAPPED'=74
'EXECUTABLE'=75
'USE'=76
'SET'=77
'RESET'=78
'SESSION'=79
'SCHEMAS'=80
'EXTRACT'=81
'QUERY'=82
'MATCH'=83
'CAST'=84
'='=85
'<'=87
'<='=88
'>'=89
'>='=90
'+'=91
'-'=92
'*'=93
'/'=94
'%'=95
'||'=96
T__0=1
T__1=2
T__2=3
T__3=4
SELECT=5
FROM=6
AS=7
ALL=8
WHEN=9
THEN=10
ANY=11
DISTINCT=12
WHERE=13
GROUP=14
BY=15
GROUPING=16
SETS=17
ORDER=18
HAVING=19
LIMIT=20
OR=21
AND=22
IN=23
NOT=24
NO=25
EXISTS=26
BETWEEN=27
LIKE=28
RLIKE=29
IS=30
NULL=31
TRUE=32
FALSE=33
LAST=34
ASC=35
DESC=36
FOR=37
INTEGER=38
JOIN=39
CROSS=40
OUTER=41
INNER=42
LEFT=43
RIGHT=44
FULL=45
NATURAL=46
USING=47
ON=48
WITH=49
TABLE=50
INTO=51
DESCRIBE=52
OPTION=53
EXPLAIN=54
ANALYZE=55
FORMAT=56
TYPE=57
TEXT=58
VERIFY=59
GRAPHVIZ=60
LOGICAL=61
PHYSICAL=62
SHOW=63
TABLES=64
COLUMNS=65
COLUMN=66
FUNCTIONS=67
TO=68
DEBUG=69
PLAN=70
PARSED=71
ANALYZED=72
OPTIMIZED=73
MAPPED=74
EXECUTABLE=75
USE=76
SET=77
RESET=78
SESSION=79
SCHEMAS=80
EXTRACT=81
QUERY=82
MATCH=83
CAST=84
EQ=85
NEQ=86
LT=87
LTE=88
GT=89
GTE=90
PLUS=91
MINUS=92
ASTERISK=93
SLASH=94
PERCENT=95
CONCAT=96
STRING=97
INTEGER_VALUE=98
DECIMAL_VALUE=99
IDENTIFIER=100
DIGIT_IDENTIFIER=101
QUOTED_IDENTIFIER=102
BACKQUOTED_IDENTIFIER=103
SIMPLE_COMMENT=104
BRACKETED_COMMENT=105
WS=106
UNRECOGNIZED=107
DELIMITER=108
'('=1
')'=2
','=3
'.'=4
'SELECT'=5
'FROM'=6
'AS'=7
'ALL'=8
'WHEN'=9
'THEN'=10
'ANY'=11
'DISTINCT'=12
'WHERE'=13
'GROUP'=14
'BY'=15
'GROUPING'=16
'SETS'=17
'ORDER'=18
'HAVING'=19
'LIMIT'=20
'OR'=21
'AND'=22
'IN'=23
'NOT'=24
'NO'=25
'EXISTS'=26
'BETWEEN'=27
'LIKE'=28
'RLIKE'=29
'IS'=30
'NULL'=31
'TRUE'=32
'FALSE'=33
'LAST'=34
'ASC'=35
'DESC'=36
'FOR'=37
'INTEGER'=38
'JOIN'=39
'CROSS'=40
'OUTER'=41
'INNER'=42
'LEFT'=43
'RIGHT'=44
'FULL'=45
'NATURAL'=46
'USING'=47
'ON'=48
'WITH'=49
'TABLE'=50
'INTO'=51
'DESCRIBE'=52
'OPTION'=53
'EXPLAIN'=54
'ANALYZE'=55
'FORMAT'=56
'TYPE'=57
'TEXT'=58
'VERIFY'=59
'GRAPHVIZ'=60
'LOGICAL'=61
'PHYSICAL'=62
'SHOW'=63
'TABLES'=64
'COLUMNS'=65
'COLUMN'=66
'FUNCTIONS'=67
'TO'=68
'DEBUG'=69
'PLAN'=70
'PARSED'=71
'ANALYZED'=72
'OPTIMIZED'=73
'MAPPED'=74
'EXECUTABLE'=75
'USE'=76
'SET'=77
'RESET'=78
'SESSION'=79
'SCHEMAS'=80
'EXTRACT'=81
'QUERY'=82
'MATCH'=83
'CAST'=84
'='=85
'<'=87
'<='=88
'>'=89
'>='=90
'+'=91
'-'=92
'*'=93
'/'=94
'%'=95
'||'=96

View File

@ -1,202 +1,202 @@
T__0=1
T__1=2
T__2=3
T__3=4
SELECT=5
FROM=6
AS=7
ALL=8
WHEN=9
THEN=10
ANY=11
DISTINCT=12
WHERE=13
GROUP=14
BY=15
GROUPING=16
SETS=17
ORDER=18
HAVING=19
LIMIT=20
OR=21
AND=22
IN=23
NOT=24
NO=25
EXISTS=26
BETWEEN=27
LIKE=28
RLIKE=29
IS=30
NULL=31
TRUE=32
FALSE=33
LAST=34
ASC=35
DESC=36
FOR=37
INTEGER=38
JOIN=39
CROSS=40
OUTER=41
INNER=42
LEFT=43
RIGHT=44
FULL=45
NATURAL=46
USING=47
ON=48
WITH=49
TABLE=50
INTO=51
DESCRIBE=52
OPTION=53
EXPLAIN=54
ANALYZE=55
FORMAT=56
TYPE=57
TEXT=58
VERIFY=59
GRAPHVIZ=60
LOGICAL=61
PHYSICAL=62
SHOW=63
TABLES=64
COLUMNS=65
COLUMN=66
FUNCTIONS=67
TO=68
DEBUG=69
PLAN=70
PARSED=71
ANALYZED=72
OPTIMIZED=73
MAPPED=74
EXECUTABLE=75
USE=76
SET=77
RESET=78
SESSION=79
SCHEMAS=80
EXTRACT=81
QUERY=82
MATCH=83
CAST=84
EQ=85
NEQ=86
LT=87
LTE=88
GT=89
GTE=90
PLUS=91
MINUS=92
ASTERISK=93
SLASH=94
PERCENT=95
CONCAT=96
STRING=97
INTEGER_VALUE=98
DECIMAL_VALUE=99
IDENTIFIER=100
DIGIT_IDENTIFIER=101
QUOTED_IDENTIFIER=102
BACKQUOTED_IDENTIFIER=103
SIMPLE_COMMENT=104
BRACKETED_COMMENT=105
WS=106
UNRECOGNIZED=107
'('=1
')'=2
','=3
'.'=4
'SELECT'=5
'FROM'=6
'AS'=7
'ALL'=8
'WHEN'=9
'THEN'=10
'ANY'=11
'DISTINCT'=12
'WHERE'=13
'GROUP'=14
'BY'=15
'GROUPING'=16
'SETS'=17
'ORDER'=18
'HAVING'=19
'LIMIT'=20
'OR'=21
'AND'=22
'IN'=23
'NOT'=24
'NO'=25
'EXISTS'=26
'BETWEEN'=27
'LIKE'=28
'RLIKE'=29
'IS'=30
'NULL'=31
'TRUE'=32
'FALSE'=33
'LAST'=34
'ASC'=35
'DESC'=36
'FOR'=37
'INTEGER'=38
'JOIN'=39
'CROSS'=40
'OUTER'=41
'INNER'=42
'LEFT'=43
'RIGHT'=44
'FULL'=45
'NATURAL'=46
'USING'=47
'ON'=48
'WITH'=49
'TABLE'=50
'INTO'=51
'DESCRIBE'=52
'OPTION'=53
'EXPLAIN'=54
'ANALYZE'=55
'FORMAT'=56
'TYPE'=57
'TEXT'=58
'VERIFY'=59
'GRAPHVIZ'=60
'LOGICAL'=61
'PHYSICAL'=62
'SHOW'=63
'TABLES'=64
'COLUMNS'=65
'COLUMN'=66
'FUNCTIONS'=67
'TO'=68
'DEBUG'=69
'PLAN'=70
'PARSED'=71
'ANALYZED'=72
'OPTIMIZED'=73
'MAPPED'=74
'EXECUTABLE'=75
'USE'=76
'SET'=77
'RESET'=78
'SESSION'=79
'SCHEMAS'=80
'EXTRACT'=81
'QUERY'=82
'MATCH'=83
'CAST'=84
'='=85
'<'=87
'<='=88
'>'=89
'>='=90
'+'=91
'-'=92
'*'=93
'/'=94
'%'=95
'||'=96
T__0=1
T__1=2
T__2=3
T__3=4
SELECT=5
FROM=6
AS=7
ALL=8
WHEN=9
THEN=10
ANY=11
DISTINCT=12
WHERE=13
GROUP=14
BY=15
GROUPING=16
SETS=17
ORDER=18
HAVING=19
LIMIT=20
OR=21
AND=22
IN=23
NOT=24
NO=25
EXISTS=26
BETWEEN=27
LIKE=28
RLIKE=29
IS=30
NULL=31
TRUE=32
FALSE=33
LAST=34
ASC=35
DESC=36
FOR=37
INTEGER=38
JOIN=39
CROSS=40
OUTER=41
INNER=42
LEFT=43
RIGHT=44
FULL=45
NATURAL=46
USING=47
ON=48
WITH=49
TABLE=50
INTO=51
DESCRIBE=52
OPTION=53
EXPLAIN=54
ANALYZE=55
FORMAT=56
TYPE=57
TEXT=58
VERIFY=59
GRAPHVIZ=60
LOGICAL=61
PHYSICAL=62
SHOW=63
TABLES=64
COLUMNS=65
COLUMN=66
FUNCTIONS=67
TO=68
DEBUG=69
PLAN=70
PARSED=71
ANALYZED=72
OPTIMIZED=73
MAPPED=74
EXECUTABLE=75
USE=76
SET=77
RESET=78
SESSION=79
SCHEMAS=80
EXTRACT=81
QUERY=82
MATCH=83
CAST=84
EQ=85
NEQ=86
LT=87
LTE=88
GT=89
GTE=90
PLUS=91
MINUS=92
ASTERISK=93
SLASH=94
PERCENT=95
CONCAT=96
STRING=97
INTEGER_VALUE=98
DECIMAL_VALUE=99
IDENTIFIER=100
DIGIT_IDENTIFIER=101
QUOTED_IDENTIFIER=102
BACKQUOTED_IDENTIFIER=103
SIMPLE_COMMENT=104
BRACKETED_COMMENT=105
WS=106
UNRECOGNIZED=107
'('=1
')'=2
','=3
'.'=4
'SELECT'=5
'FROM'=6
'AS'=7
'ALL'=8
'WHEN'=9
'THEN'=10
'ANY'=11
'DISTINCT'=12
'WHERE'=13
'GROUP'=14
'BY'=15
'GROUPING'=16
'SETS'=17
'ORDER'=18
'HAVING'=19
'LIMIT'=20
'OR'=21
'AND'=22
'IN'=23
'NOT'=24
'NO'=25
'EXISTS'=26
'BETWEEN'=27
'LIKE'=28
'RLIKE'=29
'IS'=30
'NULL'=31
'TRUE'=32
'FALSE'=33
'LAST'=34
'ASC'=35
'DESC'=36
'FOR'=37
'INTEGER'=38
'JOIN'=39
'CROSS'=40
'OUTER'=41
'INNER'=42
'LEFT'=43
'RIGHT'=44
'FULL'=45
'NATURAL'=46
'USING'=47
'ON'=48
'WITH'=49
'TABLE'=50
'INTO'=51
'DESCRIBE'=52
'OPTION'=53
'EXPLAIN'=54
'ANALYZE'=55
'FORMAT'=56
'TYPE'=57
'TEXT'=58
'VERIFY'=59
'GRAPHVIZ'=60
'LOGICAL'=61
'PHYSICAL'=62
'SHOW'=63
'TABLES'=64
'COLUMNS'=65
'COLUMN'=66
'FUNCTIONS'=67
'TO'=68
'DEBUG'=69
'PLAN'=70
'PARSED'=71
'ANALYZED'=72
'OPTIMIZED'=73
'MAPPED'=74
'EXECUTABLE'=75
'USE'=76
'SET'=77
'RESET'=78
'SESSION'=79
'SCHEMAS'=80
'EXTRACT'=81
'QUERY'=82
'MATCH'=83
'CAST'=84
'='=85
'<'=87
'<='=88
'>'=89
'>='=90
'+'=91
'-'=92
'*'=93
'/'=94
'%'=95
'||'=96

View File

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

View File

@ -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}
*

View File

@ -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}
*

View File

@ -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

View File

@ -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

View File

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

View File

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

View File

@ -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;
}
}

View File

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