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

EQL: Add field resolution and verification #51872

Merged
merged 1 commit into from
Feb 5, 2020

Conversation

costin
Copy link
Member

@costin costin commented Feb 4, 2020

Add basic field resolution inside the Analyzer and a basic Verifier to
check for any unresolved fields

@costin costin added the :Analytics/EQL EQL querying label Feb 4, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/EQL)

Add basic field resolution inside the Analyzer and a basic Verifier to
check for any unresolved fields
@costin costin force-pushed the eql/add-basic-analysis branch from 9434d38 to 14893bf Compare February 4, 2020 16:03
}
}

abstract static class AnalyzeRule<SubPlan extends LogicalPlan> extends Rule<SubPlan, LogicalPlan> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be a separate PR to externalize this to QL so it can be shared across SQL and EQL.

public abstract class LogicalPlanBuilder extends ExpressionBuilder {

// TODO: these need to be made configurable
private static final String EVENT_TYPE = "event.category";
private static final EsIndex esIndex = new EsIndex("<not-specified>", emptyMap());
private static final String EVENT_TYPE = "event_type";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this since the data sample from existing EQL documentation uses event_type. If the default field should be changed, that is best addressed separately:

  • figure out what's the impact on backwards compatibility (ECS schema) and existing data
  • update datasets
  • update code (last).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was assuming that the data will be in ECS format

    "user": {
        "group": {}
    },
    "host": {
        "os": {
            "platform": "windows",
            "name": "Windows"
        },
        "ip": "127.0.0.1",
        "hostname": "localhost",
        "name": "localhost"
    },
    "event": {
        "module": "endgame",
        "dataset": "esensor",
        "action": "already_running",
        "category": "process",
        "kind": "event"
    }, 

thus the event.category for EVENT_TYPE

@costin
Copy link
Member Author

costin commented Feb 4, 2020

Follow-up issue to beef the verifier tests further here: #51873

@@ -43,6 +39,6 @@ public LogicalPlan visitEventQuery(EqlBaseParser.EventQueryContext ctx) {

}

return new Filter(source(ctx), new EsRelation(Source.EMPTY, esIndex, false), condition);
return new Filter(source(ctx), new UnresolvedRelation(Source.EMPTY, null, "", false, ""), condition);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -89,11 +89,11 @@ public boolean equals(Object obj) {
}

UnresolvedRelation other = (UnresolvedRelation) obj;
return source().equals(other.source())
&& table.equals(other.table)
return Objects.equals(source(), other.source())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does source() need to be checked here, but isn't in some of the other hashCode and equals functions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an inconsistency - the source isn't relevant. Likely for UnresolvedRelation was added since a table or index declaration is not common and thus, its source was considered relevant.
The change above was added to avoid a NPE caused by a null (vs an empty) location.

}

return u.withUnresolvedMessage(
"Reference [" + u.qualifiedName() + "] is ambiguous (to disambiguate use quotes or qualifiers); matches any of "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may have to come back and clarify "quotes" in this message for #51443

Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@costin costin merged commit 7087358 into elastic:master Feb 5, 2020
@costin costin deleted the eql/add-basic-analysis branch February 5, 2020 11:33
costin added a commit that referenced this pull request Feb 5, 2020
* EQL: Plug query params into the AstBuilder (#51886)

As the eventType is customizable, plug that into the parser based on the
given request.

(cherry picked from commit 5b4a3a3)

* EQL: Add field resolution and verification (#51872)

Add basic field resolution inside the Analyzer and a basic Verifier to
check for any unresolved fields.

(cherry picked from commit 7087358)

* EQL: Introduce basic execution pipeline (#51809)

Add main classes that form the 'execution' pipeline are added - most of
them have no functionality; the purpose of this PR is to add flesh out
the contract between the various moving parts so that work can start on
them independently.

(cherry picked from commit 9a1bae5)

* EQL: Add AstBuilder to convert to QL tree (#51558)

* EQL: Add AstBuilder visitors
* EQL: Add tests for wildcards and sets
* EQL: Fix licensing
* EQL: Fix ExpressionTests.java license
* EQL: Cleanup imports
* EQL: PR feedback and remove LiteralBuilder
* EQL: Split off logical plan from expressions
* EQL: Remove stray import
* EQL: Add predicate handling for set checks
* EQL: Remove commented out dead code
* EQL: Remove wildcard test, wait until analyzer

(cherry picked from commit a462700)

* EQL grammar updates and tests (#49658)

* EQL: Additional tests and grammar updates
* EQL: Add backtick escaped identifiers
* EQL: Adding keywords to language
* EQL: Add checks for unsupported syntax
* EQL: Testing updates and PR feedback
* EQL: Add string escapes
* EQL: Cleanup grammar for identifier
* EQL: Remove tabs from .eql tests

(cherry picked from commit 6f1890b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/EQL EQL querying
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants