Compare commits
No commits in common. "35b5c1b41bf6767c5837640846a1663078cebb67" and "a8efef907a3f3c7422f87fbb178e14e46df25652" have entirely different histories.
35b5c1b41b
...
a8efef907a
@ -24,9 +24,6 @@ rule read_token = parse
|
|||||||
| "ON" { ON }
|
| "ON" { ON }
|
||||||
| "WHERE" { WHERE }
|
| "WHERE" { WHERE }
|
||||||
| "HAVING" { HAVING }
|
| "HAVING" { HAVING }
|
||||||
| "BETWEEN" { BETWEEN }
|
|
||||||
| "IN" { IN }
|
|
||||||
| "LIKE" { LIKE }
|
|
||||||
| "GROUP" { GROUP }
|
| "GROUP" { GROUP }
|
||||||
| "BY" { BY }
|
| "BY" { BY }
|
||||||
| "*" { ASTERISK }
|
| "*" { ASTERISK }
|
||||||
@ -35,7 +32,6 @@ rule read_token = parse
|
|||||||
| "(" { LEFT_PAREN }
|
| "(" { LEFT_PAREN }
|
||||||
| ")" { RIGHT_PAREN }
|
| ")" { RIGHT_PAREN }
|
||||||
| "," { COMMA }
|
| "," { COMMA }
|
||||||
| "|" { PIPE }
|
|
||||||
| whitespace { read_token lexbuf }
|
| whitespace { read_token lexbuf }
|
||||||
| alpha alphanumeric* as ident { IDENT ident }
|
| alpha alphanumeric* as ident { IDENT ident }
|
||||||
| eof { EOF }
|
| eof { EOF }
|
||||||
|
42
lib/ast.ml
42
lib/ast.ml
@ -26,7 +26,6 @@ and predicate =
|
|||||||
| NotBetween of string * string
|
| NotBetween of string * string
|
||||||
| In of string list
|
| In of string list
|
||||||
| NotIn of string list
|
| NotIn of string list
|
||||||
| Like of string
|
|
||||||
and operator =
|
and operator =
|
||||||
| Equals
|
| Equals
|
||||||
| NotEquals
|
| NotEquals
|
||||||
@ -38,44 +37,3 @@ and filter =
|
|||||||
| Filter of string
|
| Filter of string
|
||||||
and search_condition =
|
and search_condition =
|
||||||
| Search of string
|
| Search of string
|
||||||
|
|
||||||
|
|
||||||
let rec pp_query ast =
|
|
||||||
match ast with
|
|
||||||
| Query(s) -> pp_select s
|
|
||||||
|
|
||||||
and pp_select s =
|
|
||||||
match s with
|
|
||||||
| Select(cols, _) -> pp_columns cols
|
|
||||||
|
|
||||||
and pp_columns cols =
|
|
||||||
match cols with
|
|
||||||
| [] -> ""
|
|
||||||
| [col] -> pp_column col
|
|
||||||
| col::l -> pp_column col ^ ";" ^ pp_columns l
|
|
||||||
|
|
||||||
and pp_column col =
|
|
||||||
match col with
|
|
||||||
| Column(name) -> name
|
|
||||||
| Asterisk -> "*"
|
|
||||||
|
|
||||||
and pp_tables tables =
|
|
||||||
match tables with
|
|
||||||
| [] -> ""
|
|
||||||
| [table] -> pp_table table
|
|
||||||
| table::l -> pp_table table ^ ";" ^ pp_tables l
|
|
||||||
|
|
||||||
and pp_table table =
|
|
||||||
match table with
|
|
||||||
| Table(table) -> table
|
|
||||||
| Join(t1, j, t2, _) -> pp_table t1 ^ pp_join_type j ^ pp_table t2
|
|
||||||
|
|
||||||
and pp_join_type j =
|
|
||||||
match j with
|
|
||||||
| Inner -> "inner"
|
|
||||||
| Left -> "left"
|
|
||||||
| Right -> "right"
|
|
||||||
| Full -> "full"
|
|
||||||
| Cross -> "cross"
|
|
||||||
| Union -> "union"
|
|
||||||
| Natural -> "natural"
|
|
||||||
|
@ -4,14 +4,14 @@ open Ast
|
|||||||
%}
|
%}
|
||||||
|
|
||||||
%token CREATE TABLE
|
%token CREATE TABLE
|
||||||
%token SELECT ALL DISTINCT FROM WHERE HAVING BETWEEN IN LIKE
|
%token SELECT ALL DISTINCT FROM WHERE HAVING BETWEEN IN
|
||||||
%token LEFT RIGHT FULL INNER OUTER
|
%token LEFT RIGHT FULL INNER OUTER
|
||||||
%token CROSS NATURAL UNION JOIN
|
%token CROSS NATURAL UNION JOIN
|
||||||
%token GREATER_THAN_OPERATOR LESS_THAN_OPERATOR EQUALS_OPERATOR
|
%token GREATER_THAN_OPERATOR LESS_THAN_OPERATOR EQUALS_OPERATOR
|
||||||
%token MAX MIN SUM COUNT AVG
|
%token MAX MIN SUM COUNT AVG
|
||||||
%token ASYMMETRIC SYMMETRIC
|
%token ASYMMETRIC SYMMETRIC
|
||||||
%token <string> IDENT
|
%token <string> IDENT
|
||||||
%token COMMA DOT PIPE
|
%token COMMA DOT
|
||||||
%token LEFT_PAREN RIGHT_PAREN
|
%token LEFT_PAREN RIGHT_PAREN
|
||||||
%token ASTERISK
|
%token ASTERISK
|
||||||
%token AS ON GROUP BY FILTER
|
%token AS ON GROUP BY FILTER
|
||||||
@ -165,7 +165,7 @@ predicate :
|
|||||||
| comparison_predicate { $1 }
|
| comparison_predicate { $1 }
|
||||||
| between_predicate { $1 }
|
| between_predicate { $1 }
|
||||||
| in_predicate { $1 }
|
| in_predicate { $1 }
|
||||||
(* | like_predicate { $1 } *)
|
| like_predicate { $1 }
|
||||||
|
|
||||||
comparison_predicate :
|
comparison_predicate :
|
||||||
| row_value_predicand comparison_predicate_part2 { Condition($1, $2) }
|
| row_value_predicand comparison_predicate_part2 { Condition($1, $2) }
|
||||||
@ -199,36 +199,6 @@ in_value_list:
|
|||||||
| row_value_expression { [$1] }
|
| row_value_expression { [$1] }
|
||||||
| in_value_list COMMA row_value_expression { $3::$1 }
|
| in_value_list COMMA row_value_expression { $3::$1 }
|
||||||
|
|
||||||
like_predicate :
|
|
||||||
| character_like_predicate { $1 }
|
|
||||||
|
|
||||||
character_like_predicate :
|
|
||||||
| row_value_predicand character_like_predicate_part2 { }
|
|
||||||
|
|
||||||
character_like_predicate_part2:
|
|
||||||
| LIKE character_pattern {}
|
|
||||||
| NOT LIKE character_pattern {}
|
|
||||||
|
|
||||||
character_pattern :
|
|
||||||
| character_value_expression {}
|
|
||||||
|
|
||||||
character_value_expression:
|
|
||||||
| concatenation {}
|
|
||||||
| character_factor {}
|
|
||||||
|
|
||||||
concatenation:
|
|
||||||
| character_value_expression concatenation_operator character_factor {}
|
|
||||||
|
|
||||||
character_factor :
|
|
||||||
| character_primary {}
|
|
||||||
|
|
||||||
character_primary:
|
|
||||||
| value_expression_primary {}
|
|
||||||
(* | string_value_function {} *)
|
|
||||||
|
|
||||||
concatenation_operator:
|
|
||||||
| PIPE PIPE {}
|
|
||||||
|
|
||||||
row_value_expression :
|
row_value_expression :
|
||||||
| row_value_special_case { $1 }
|
| row_value_special_case { $1 }
|
||||||
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
open Ast
|
|
||||||
|
|
||||||
let parse query =
|
|
||||||
let lexbuf = Lexing.from_string query in
|
|
||||||
Parser.main Lexer.read_token lexbuf
|
|
||||||
|
|
||||||
let equal_ast ast1 ast2 =
|
|
||||||
ast1 = ast2
|
|
||||||
|
|
||||||
let
|
|
||||||
|
|
||||||
let test_simple_select() =
|
|
||||||
let q1 = parse "SELECT a FROM t" in
|
|
||||||
let ast1 = Query(Select([Column("a")], [Table("t")])) in
|
|
||||||
Alcotest.(check
|
|
File diff suppressed because it is too large
Load Diff
@ -1,113 +0,0 @@
|
|||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* fb303.thrift
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace java com.facebook.fb303
|
|
||||||
namespace cpp facebook.fb303
|
|
||||||
namespace perl Facebook.FB303
|
|
||||||
namespace netstd Facebook.FB303.Test
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Common status reporting mechanism across all services
|
|
||||||
*/
|
|
||||||
enum fb_status {
|
|
||||||
DEAD = 0,
|
|
||||||
STARTING = 1,
|
|
||||||
ALIVE = 2,
|
|
||||||
STOPPING = 3,
|
|
||||||
STOPPED = 4,
|
|
||||||
WARNING = 5,
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Standard base service
|
|
||||||
*/
|
|
||||||
service FacebookService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a descriptive name of the service
|
|
||||||
*/
|
|
||||||
string getName(),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the version of the service
|
|
||||||
*/
|
|
||||||
string getVersion(),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the status of this service
|
|
||||||
*/
|
|
||||||
fb_status getStatus(),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User friendly description of status, such as why the service is in
|
|
||||||
* the dead or warning state, or what is being started or stopped.
|
|
||||||
*/
|
|
||||||
string getStatusDetails(),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the counters for this service
|
|
||||||
*/
|
|
||||||
map<string, i64> getCounters(),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the value of a single counter
|
|
||||||
*/
|
|
||||||
i64 getCounter(1: string key),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets an option
|
|
||||||
*/
|
|
||||||
void setOption(1: string key, 2: string value),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets an option
|
|
||||||
*/
|
|
||||||
string getOption(1: string key),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all options
|
|
||||||
*/
|
|
||||||
map<string, string> getOptions(),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a CPU profile over the given time interval (client and server
|
|
||||||
* must agree on the profile format).
|
|
||||||
*/
|
|
||||||
string getCpuProfile(1: i32 profileDurationInSec),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the unix time that the server has been running since
|
|
||||||
*/
|
|
||||||
i64 aliveSince(),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tell the server to reload its configuration, reopen log files, etc
|
|
||||||
*/
|
|
||||||
oneway void reinitialize(),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Suggest a shutdown to the server
|
|
||||||
*/
|
|
||||||
oneway void shutdown(),
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user