All Projects → yahoo → yql-plus

yahoo / yql-plus

Licence: Apache-2.0 License
The YQL+ parser, execution engine, and source SDK.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to yql-plus

djaq
Django queries
Stars: ✭ 54 (+50%)
Mutual labels:  query-language
viziquer
Tool for Search in Structured Semantic Data
Stars: ✭ 12 (-66.67%)
Mutual labels:  query-language
twinql
A graph query language for the semantic web
Stars: ✭ 17 (-52.78%)
Mutual labels:  query-language
kql
Kirby's Query Language API combines the flexibility of Kirby's data structures, the power of GraphQL and the simplicity of REST.
Stars: ✭ 120 (+233.33%)
Mutual labels:  query-language
qcert
Compilation and Verification of Data-Centric Languages
Stars: ✭ 50 (+38.89%)
Mutual labels:  query-language
hdq
HTML DOM Query Language for Go+
Stars: ✭ 28 (-22.22%)
Mutual labels:  query-language
fat ecto
Query mechanism for Ecto
Stars: ✭ 20 (-44.44%)
Mutual labels:  query-language
vaultaire
Query DSL and data access utilities for Corda developers.
Stars: ✭ 14 (-61.11%)
Mutual labels:  query-language
miniql
A tiny JSON-based query language inspired by GraphQL
Stars: ✭ 121 (+236.11%)
Mutual labels:  query-language
jmespath.rs
Rust implementation of JMESPath, a query language for JSON
Stars: ✭ 84 (+133.33%)
Mutual labels:  query-language
cql
Clincal Quality Language Specification
Stars: ✭ 16 (-55.56%)
Mutual labels:  query-language
freebase-mql
A review of the deprecated Freebase knowledge base and Metaweb Query Language (MQL). A brief comparison of MQL and GraphQL.
Stars: ✭ 41 (+13.89%)
Mutual labels:  query-language
xquery-power
A list of resources built on or with XQuery
Stars: ✭ 25 (-30.56%)
Mutual labels:  query-language
grafito
Portable, Serverless & Lightweight SQLite-based Graph Database in Arturo
Stars: ✭ 95 (+163.89%)
Mutual labels:  query-language
m-custom-functions
This library contains created mostly pure M-functions without any other languages.
Stars: ✭ 24 (-33.33%)
Mutual labels:  query-language
Judge-Jury-and-Executable
A file system forensics analysis scanner and threat hunting tool. Scans file systems at the MFT and OS level and stores data in SQL, SQLite or CSV. Threats and data can be probed harnessing the power and syntax of SQL.
Stars: ✭ 66 (+83.33%)
Mutual labels:  query-language
vm
The mm-ADT Virtual Machine
Stars: ✭ 29 (-19.44%)
Mutual labels:  query-language
gsql
GSQL is a structured query language code builder for golang.
Stars: ✭ 106 (+194.44%)
Mutual labels:  query-language
DocumentLab
OCR using tesseract, ImageMagick, EmguCV, an advanced query language and a fluent query interface for C#
Stars: ✭ 64 (+77.78%)
Mutual labels:  query-language
joern
Open-source code analysis platform for C/C++/Java/Binary/Javascript/Python/Kotlin based on code property graphs
Stars: ✭ 968 (+2588.89%)
Mutual labels:  query-language

Build Status

YQL+ Engine

This is the YQL+ parser, execution engine, and source SDK.

Modules

  • yqlplus_language - YQL+ grammar and parser

    An ANTLRv4-based parser for the YQL+ grammar (see docs/language.md) which parses programs into "OperatorNodes" -- an AST representation of a YQL+ program consisting of OperatorNodes of different types of operators:

    • StatementOperator - The top-level PROGRAM as well as argument declarations, view statements, queries, etc.
    • SequenceOperators - Represents queries. Logically produces a sequence of records, includes operators like PROJECT, FILTER, SCAN
    • ExpressionOperator - Represents an expression -- used to represent projection expressions, filters, sorts, etc.
    • SortOperator - Represents ASC and DESC operators on sort expressions.
    • ProjectOperator - Operations in a projection -- FIELD, FLATTEN (SELECT a.* ...)
  • yqlplus_engine -- YQL+ execution engine

    This is the engine implementation. It has APIs for turning a stream or file into a CompiledProgram which is the interface for executing a program and getting results.

  • yqlplus_source_api -- Source annotations and interfaces

This module defines the API for writing sources, transforms (pipes), and UDFs. It contains interfaces for tagging an implementation of each as well as annotations for communicating binding information to the engine.

Guice Multibindings are used to publish these implementations to the engine with names.

Usage

  • YQL+ language parser
ProgramParser parser = new ProgramParser();
parser.parse("query", 
             "PROGRAM (@uuid string,
                       @logo_type string=""); 
              SELECT p.id,
                     p.provider_id, 
                     p.provider_name,
                     p.provider_alias,  
                    {"name" : plogo.name, "image" :  plogo.image} logo
              FROM provider({}) AS p 
              LEFT JOIN provider_logo(@logo_type,{}) AS plogo 
              ON p.id = plogo.provider_id  
              WHERE p.id=@uuid
              OUTPUT AS provider;");
  • Query a Data Source

    (1) Create a Data Source

  public class InnerSource implements Source {
      @Query
      @TimeoutBudget(minimumMilliseconds = 5, maximumMilliseconds = 100)
      public List<Person> scan(@TimeoutMilliseconds long timeoutMs) {
        Assert.assertTrue(timeoutMs <= 100, "timeoutBudget <= 100");
        // checking minimum is dodgy and leads to failures
        return ImmutableList.of(new Person("1", "joe", 1));
      }

      @Query
      public Person lookup(@Key("id") String id) {
        if ("1".equals(id)) {
            return new Person("1", "joe", 1);
        } else if ("3".equals(id)) {
            return new Person("3", "smith", 1);
        } else {
            return null;
        }
      }

      @Query
      public Person lookup(@Key("iid") Integer id) {
        return lookup(String.valueOf(id));
      }
  }

(2) Bind Source instance

public class JavaTestModule extends AbstractModule {
   @Override
    protected void configure() {
        install(new JavaEngineModule());
        MapBinder<String, Source> sourceBindings = MapBinder.newMapBinder(binder(), String.class, Source.class);
        sourceBindings.addBinding("innersource").to(InnerSource.class);
    }
}

(3) Create Program to query the Data Source

Injector injector = Guice.createInjector(new JavaTestModule());
YQLPlusCompiler compiler = injector.getInstance(YQLPlusCompiler.class);
CompiledProgram program = compiler.compile("SELECT * FROM innersource WHERE id = '1' OUTPUT AS b1;");
ProgramResult myResult = program.run(ImmutableMap.<String, Object>of(), true);
YQLResultSet b1 = myResult.getResult("b1").get();
List<Person> b1r = b1.getResult();
 
  • Import Java function to YQL+ Program

    (1) Create an Export class

  public class DateTime implements Exports {

      @Export
      public Instant from_epoch_second(long epochSecond) {
          return Instant.ofEpochSecond(epochSecond);
      }
  }

(2) Bind Export class

public class StandardLibraryModule extends AbstractModule {

    @Override
    protected void configure() {
        MapBinder<String, Exports> exportsBindings = MapBinder.newMapBinder(binder(), String.class, Exports.class);
        exportsBindings.addBinding("datetime").to(DateTime.class);
    }
}

(3) Use the Export function in Program

YQLPlusCompiler compiler = injector.getInstance(YQLPlusCompiler.class);
CompiledProgram program = compiler.compile("SELECT datetime.from_epoch_second(1378489457) date OUTPUT AS d1;");
ProgramResult result = program.run(ImmutableMap.<String, Object>of(), false);
List<Record> f2 = result.getResult("d1").get().getResult();

Maven

   
   <dependency>
      <groupId>com.yahoo.yqlplus</groupId>
      <artifactId>yqlplus_engine</artifactId>
      <version>1.0.1</version>
   </dependency>
   ...
   <dependency>   
      <groupId>com.yahoo.yqlplus</groupId>
      <artifactId>yqlplus_source_api</artifactId>
      <version>$1.0.1</version>
   </dependency>
   ...
   <dependency>   
      <groupId>com.yahoo.yqlplus</groupId>
      <artifactId>yqlplus_language</artifactId>
      <version>$1.0.1</version>
   </dependency> 
   ...
   <dependency>
      <groupId>com.yahoo.yqlplus</groupId>
      <artifactId>yqlplus_stdlib</artifactId>
      <version>1.0.1</version>
   </dependency>
   ...
   <repositories>
      <repository>
        <snapshots>
          <enabled>false</enabled>
        </snapshots>
        <id>bintray-yahoo-maven</id>
        <name>bintray</name>
        <url>http://yahoo.bintray.com/maven</url>
      </repository>
   </repositories>

LICENSE

Copyright 2016 Yahoo Inc.

Licensed under the terms of the Apache version 2.0 license. See LICENSE file for terms.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].