Giter VIP home page Giter VIP logo

sparkql's Introduction

SparkQL query language parser

This gem contains the syntax parser for processing spark api filter queries into manageable expressions. To get an overview of the language syntax-wise, refer to the following files:

  • lib/sparkql/parser.y # BNF Grammar
  • lib/sparkql/token.rb # Token matching rules

Installation

Add the gem to your gemfile:

Gemfile gem 'sparkql', '~> 0.0.1'

When completed, run 'bundle install'.

Usage

Ruby 1.9 or greater is required.

See test/unit/parser_test.rb for generic parsing examples. In most cases an extended parser is needed to do anything of significance, such as the postgres and db2 search implementations in the API.

Here is a basic example:

expressions = Parser.new.parse("Hello Eq 'World'")

The return value will be an array with one expression element containing the query information:

{
  :field => "Hello",
  :type => :character,
  :value => "'World'",
  :operator => 'Eq'
  # ...
}

Development

The parser is based on racc, a yacc like LR parser that is a part of the ruby runtime. The grammar is located at lib/sparkql/parser.y and is compiled as part of the test process. Refer to the Rakefile for details. When modifying the grammar, please checkin BOTH the parser.y and parser.rb files.

Debugging grammar issues can be done by hand using the "racc" command. For example, a dump of the parser states (and conflicts) can be generated via

racc -o lib/sparkql/parser.rb lib/sparkql/parser.y -v  # see lib/sparkql/parser.output

The rails/journey project was an inspiration for this gem. Look it up on github for reference.

sparkql's People

Contributors

wlmcewen avatar codygustafson avatar bhornseth avatar joshcom avatar ridley-james avatar aquamme avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.