Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESQL: Clone ql for esql #108773

Merged
merged 25 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
092cbfc
Use a clone of ql in esql, esql-core
alex-spies May 16, 2024
cf6ceee
Update build.gradle files
alex-spies May 17, 2024
5d51427
Add readme
alex-spies May 17, 2024
6cf3d13
Update benchmark deps
alex-spies May 17, 2024
446602a
Fix EsqlNodeSubclassTests
alex-spies May 17, 2024
ed43de0
Fix multi-cluster-search-security
alex-spies May 17, 2024
8bb5d62
Merge remote-tracking branch 'upstream/main' into clone-ql-for-esql
alex-spies May 21, 2024
d29fdee
Address Luigi's remarks
alex-spies May 21, 2024
a571d61
Commit Luigi's ql migration script
alex-spies May 21, 2024
058076f
Update Luigi's script
alex-spies May 21, 2024
d54fe19
Rename package ql -> esql.core
alex-spies May 21, 2024
634afa6
Fix bwc tests
alex-spies May 21, 2024
2b9d768
Remove Luigi's script
alex-spies May 21, 2024
c39c6e8
Spotless + checkStyle
alex-spies May 21, 2024
9671841
More checkStyle
alex-spies May 21, 2024
3bb0744
Update esql-core's README.md
alex-spies May 21, 2024
e52f031
Update forbidden signatures
alex-spies May 21, 2024
d1791c2
Fix more bwc tests
alex-spies May 21, 2024
1933aee
Fix benchmark and MlNativeIntegTestCase
alex-spies May 21, 2024
b4d92bd
Fix dependency esql -> esql-core
alex-spies May 21, 2024
d68bb33
Revert "Fix dependency esql -> esql-core"
alex-spies May 21, 2024
8afae9d
Fix CrossClusterShardTests
alex-spies May 21, 2024
f3d2060
Fix some more bwc tests
alex-spies May 21, 2024
a3f003c
Merge remote-tracking branch 'upstream/main' into clone-ql-for-esql
alex-spies May 21, 2024
b4b803c
Merge remote-tracking branch 'upstream/main' into clone-ql-for-esql
alex-spies May 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion benchmarks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
exclude group: 'net.sf.jopt-simple', module: 'jopt-simple'
}
api(project(':modules:aggregations'))
api(project(':x-pack:plugin:ql'))
api(project(':x-pack:plugin:esql-core'))
api(project(':x-pack:plugin:esql'))
api(project(':x-pack:plugin:esql:compute'))
implementation project(path: ':libs:elasticsearch-vec')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
import org.elasticsearch.compute.operator.EvalOperator;
import org.elasticsearch.compute.operator.Operator;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.xpack.esql.core.expression.FieldAttribute;
import org.elasticsearch.xpack.esql.core.expression.Literal;
import org.elasticsearch.xpack.esql.core.expression.predicate.regex.RLikePattern;
import org.elasticsearch.xpack.esql.core.tree.Source;
import org.elasticsearch.xpack.esql.core.type.DataTypes;
import org.elasticsearch.xpack.esql.core.type.EsField;
import org.elasticsearch.xpack.esql.evaluator.EvalMapper;
import org.elasticsearch.xpack.esql.expression.function.scalar.date.DateTrunc;
import org.elasticsearch.xpack.esql.expression.function.scalar.math.Abs;
Expand All @@ -31,12 +37,6 @@
import org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.Equals;
import org.elasticsearch.xpack.esql.planner.Layout;
import org.elasticsearch.xpack.esql.type.EsqlDataTypes;
import org.elasticsearch.xpack.ql.expression.FieldAttribute;
import org.elasticsearch.xpack.ql.expression.Literal;
import org.elasticsearch.xpack.ql.expression.predicate.regex.RLikePattern;
import org.elasticsearch.xpack.ql.tree.Source;
import org.elasticsearch.xpack.ql.type.DataTypes;
import org.elasticsearch.xpack.ql.type.EsField;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/esql/functions/examples/to_integer.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ The header will provide information on the source of the failure:

A following header will contain the failure reason and the offending value:

`"org.elasticsearch.xpack.ql.InvalidArgumentException: [501379200000] out of [integer] range"`
`"org.elasticsearch.xpack.esql.core.InvalidArgumentException: [501379200000] out of [integer] range"`


14 changes: 14 additions & 0 deletions x-pack/plugin/esql-core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# ES|QL core

This project originated as a copy of the `ql` x-pack plugin.
It contains some fundamental classes used in `esql`, like `Node`, its subclasses `Expression`, `QueryPlan`, and the plan optimizer code.
Originally, `ql` shared classes between ES|QL, SQL and EQL, but ES|QL diverged far enough to justify a split.

## Warning

- **Consider the contents of this project untested.**
There may be some tests in `sql` and `eql` that may have indirectly covered the initial version of this (when it was copied from `ql`);
but neither do these tests apply to `esql`, nor do they even run against this.
- **Consider this project technical debt.**
The contents of this project need to be consolidated with the `esql` plugin.
In particular, there is a significant amount of code (or code paths) that are not used/executed at all in `esql`.
24 changes: 24 additions & 0 deletions x-pack/plugin/esql-core/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apply plugin: 'elasticsearch.internal-es-plugin'
apply plugin: 'elasticsearch.internal-test-artifact'

esplugin {
name 'x-pack-esql-core'
description 'Elasticsearch infrastructure plugin for ESQL'
classname 'org.elasticsearch.xpack.esql.core.plugin.EsqlCorePlugin'
extendedPlugins = ['x-pack-core']
}

base {
archivesName = 'x-pack-esql-core'
}

dependencies {
api "org.antlr:antlr4-runtime:${versions.antlr4}"
api project(path: xpackModule('mapper-version'))
compileOnly project(path: xpackModule('core'))
testApi(project(xpackModule('esql-core:test-fixtures'))) {
exclude group: 'org.elasticsearch.plugin', module: 'esql-core'
}
testImplementation project(':test:framework')
testImplementation(testArtifact(project(xpackModule('core'))))
}
26 changes: 26 additions & 0 deletions x-pack/plugin/esql-core/licenses/antlr4-runtime-LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[The "BSD license"]
Copyright (c) 2015 Terence Parr, Sam Harwell
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.xpack.esql.core;

/**
* Exception thrown when unable to continue processing client request,
* in cases such as invalid query parameter or failure to apply requested processing to given data.
* It's meant as a generic equivalent to QlIllegalArgumentException (that's a server exception).
* TODO: reason for [E|S|ES]QL specializations of QlIllegalArgumentException?
* TODO: the intended use of ql.ParsingException, vs its [E|S|ES]QL equivalents, subclassed from the respective XxxClientException?
* Same for PlanningException.
*/
public class InvalidArgumentException extends QlClientException {

public InvalidArgumentException(String message, Object... args) {
super(message, args);
}

public InvalidArgumentException(Throwable cause, String message, Object... args) {
super(cause, message, args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

package org.elasticsearch.xpack.esql.core;

import org.elasticsearch.xpack.esql.core.tree.Source;

import static org.elasticsearch.common.logging.LoggerMessageFormat.format;

public class ParsingException extends QlClientException {
private final int line;
private final int charPositionInLine;

public ParsingException(String message, Exception cause, int line, int charPositionInLine) {
super(message, cause);
this.line = line;
this.charPositionInLine = charPositionInLine;
}

public ParsingException(String message, Object... args) {
this(Source.EMPTY, message, args);
}

public ParsingException(Source source, String message, Object... args) {
super(message, args);
this.line = source.source().getLineNumber();
this.charPositionInLine = source.source().getColumnNumber();
}

public ParsingException(Exception cause, Source source, String message, Object... args) {
super(cause, message, args);
this.line = source.source().getLineNumber();
this.charPositionInLine = source.source().getColumnNumber();
}

public int getLineNumber() {
return line;
}

public int getColumnNumber() {
return charPositionInLine + 1;
}

public String getErrorMessage() {
return super.getMessage();
}

@Override
public String getMessage() {
return format("line {}:{}: {}", getLineNumber(), getColumnNumber(), getErrorMessage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.xpack.esql.core;

import org.elasticsearch.rest.RestStatus;

/**
* Exception thrown by performing client (or user) code.
* Typically it means the given action or query is incorrect and needs fixing.
*/
public class QlClientException extends QlException {

protected QlClientException(String message, Object... args) {
super(message, args);
}

protected QlClientException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}

protected QlClientException(String message, Throwable cause) {
super(message, cause);
}

protected QlClientException(Throwable cause, String message, Object... args) {
super(cause, message, args);
}

protected QlClientException(Throwable cause) {
super(cause);
}

@Override
public RestStatus status() {
return RestStatus.BAD_REQUEST;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.xpack.esql.core;

import org.elasticsearch.ElasticsearchException;

/**
* Base class for all QL exceptions. Useful as a catch-all.
*/
public abstract class QlException extends ElasticsearchException {
public QlException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}

public QlException(String message, Throwable cause) {
super(message, cause);
}

public QlException(String message, Object... args) {
super(message, args);
}

public QlException(Throwable cause, String message, Object... args) {
super(message, cause, args);
}

public QlException(Throwable cause) {
super(cause);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.xpack.esql.core;

public class QlIllegalArgumentException extends QlServerException {
public QlIllegalArgumentException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}

public QlIllegalArgumentException(String message, Throwable cause) {
super(message, cause);
}

public QlIllegalArgumentException(String message, Object... args) {
super(message, args);
}

public QlIllegalArgumentException(Throwable cause, String message, Object... args) {
super(cause, message, args);
}

public QlIllegalArgumentException(String message) {
super(message);
}

public QlIllegalArgumentException(Throwable cause) {
super(cause);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.xpack.esql.core;

/**
* Exception triggered inside server-side code.
* Typically a validation error or worse, a bug.
*/
public abstract class QlServerException extends QlException {

protected QlServerException(String message, Object... args) {
super(message, args);
}

protected QlServerException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}

protected QlServerException(String message, Throwable cause) {
super(message, cause);
}

protected QlServerException(Throwable cause, String message, Object... args) {
super(cause, message, args);
}

protected QlServerException(Throwable cause) {
super(cause);
}
}
Loading