Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
7f8d9f02
Commit
7f8d9f02
authored
Feb 09, 2015
by
Harish Butani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Query Parser initial checkin
parent
fca624df
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
0 deletions
+88
-0
QueryParser.scala
.../scala/org/apache/hadoop/metadata/query/QueryParser.scala
+0
-0
LexerTest.scala
...st/scala/org/apache/hadoop/metadata/query/LexerTest.scala
+30
-0
ParserTest.scala
...t/scala/org/apache/hadoop/metadata/query/ParserTest.scala
+58
-0
No files found.
typesystem/src/main/scala/org/apache/hadoop/metadata/query/QueryParser.scala
0 → 100644
View file @
7f8d9f02
This diff is collapsed.
Click to expand it.
typesystem/src/test/scala/org/apache/hadoop/metadata/query/LexerTest.scala
0 → 100644
View file @
7f8d9f02
package
org.apache.hadoop.metadata.query
import
org.junit.
{
Assert
,
Test
}
import
scala.util.parsing.input.CharArrayReader
class
LexerTest
{
def
scan
(
p
:
QueryParser
,
str
:
String
)
:
p.lexical.ParseResult
[
_
]
=
{
val
l
=
p
.
lexical
var
s
:
l.Input
=
new
CharArrayReader
(
str
.
toCharArray
)
var
r
=
(
l
.
whitespace
.?
~
l
.
token
)(
s
)
s
=
r
.
next
while
(
r
.
successful
&&
!
s
.
atEnd
)
{
s
=
r
.
next
if
(!
s
.
atEnd
)
{
r
=
(
l
.
whitespace
.?
~
l
.
token
)(
s
)
}
}
r
.
asInstanceOf
[
p.lexical.ParseResult
[
_
]]
}
@Test
def
testSimple
{
val
p
=
new
QueryParser
val
r
=
scan
(
p
,
"""DB where db1.name"""
)
Assert
.
assertTrue
(
r
.
successful
)
}
}
typesystem/src/test/scala/org/apache/hadoop/metadata/query/ParserTest.scala
0 → 100644
View file @
7f8d9f02
package
org.apache.hadoop.metadata.query
import
org.apache.hadoop.metadata.BaseTest
import
org.apache.hadoop.metadata.query.Expressions._
import
org.junit.
{
Test
,
Before
}
class
ParserTest
extends
BaseTest
{
@Before
override
def
setup
{
super
.
setup
QueryTestsUtils
.
setupTypes
}
@Test
def
testFrom
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
"from DB"
).
right
.
get
.
toString
)
}
@Test
def
testFrom2
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
"DB"
).
right
.
get
.
toString
)
}
@Test
def
testJoin1
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
"DB, Table"
).
right
.
get
.
toString
)
}
@Test
def
testWhere1
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
"DB as db1 Table where db1.name "
).
right
.
get
.
toString
)
}
@Test
def
testWhere2
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
"DB name = \"Reporting\""
).
right
.
get
.
toString
)
}
@Test
def
test4
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
"DB where (name = \"Reporting\") select name as _col_0, (createTime + 1) as _col_1"
).
right
.
get
.
toString
)
}
@Test
def
testJoin2
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
"DB as db1 where (createTime + 1) > 0 and (db1.name = \"Reporting\") or DB has owner Table as tab "
+
" select db1.name as dbName, tab.name as tabName"
).
right
.
get
.
toString
)
}
@Test
def
testLoop
:
Unit
=
{
val
p
=
new
QueryParser
println
(
p
(
"Table loop (LoadProcess outputTable)"
).
right
.
get
.
toString
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment