-
Notifications
You must be signed in to change notification settings - Fork 147
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
Question - how to run queryparser #57
Comments
I believe if you want to develop queryparser, you will need to use stack. However, if you want to just use queryparser in a Haskell environment, there are packages on Hackage that you can directly import. |
This starts up the shell:
This sets the shell prompt right:
This is how you can parse a simple statement of PrestoSQL: sql> Database.Sql.Presto.Parser.parse "SELECT 1;"
Right (PrestoStandardSqlStatement (QueryStmt (QuerySelect (Range {start = Position {positionLine = 1, positionColumn = 0, positionOffset = 0}, end = Position {positionLine = 1, positionColumn = 8, positionOffset = 8}}) (Select {selectInfo = Range {start = Position {positionLine = 1, positionColumn = 0, positionOffset = 0}, end = Position {positionLine = 1, positionColumn = 8, positionOffset = 8}}, selectCols = SelectColumns {selectColumnsInfo = Range {start = Position {positionLine = 1, positionColumn = 7, positionOffset = 7}, end = Position {positionLine = 1, positionColumn = 8, positionOffset = 8}}, selectColumnsList = [SelectExpr (Range {start = Position {positionLine = 1, positionColumn = 7, positionOffset = 7}, end = Position {positionLine = 1, positionColumn = 8, positionOffset = 8}}) [ColumnAlias (Range {start = Position {positionLine = 1, positionColumn = 7, positionOffset = 7}, end = Position {positionLine = 1, positionColumn = 8, positionOffset = 8}}) "_col0" (ColumnAliasId 1)] (ConstantExpr (Range {start = Position {positionLine = 1, positionColumn = 7, positionOffset = 7}, end = Position {positionLine = 1, positionColumn = 8, positionOffset = 8}}) (NumericConstant (Range {start = Position {positionLine = 1, positionColumn = 7, positionOffset = 7}, end = Position {positionLine = 1, positionColumn = 8, positionOffset = 8}}) "1"))]}, selectFrom = Nothing, selectWhere = Nothing, selectTimeseries = Nothing, selectGroup = Nothing, selectHaving = Nothing, selectNamedWindow = Nothing, selectDistinct = Distinct False})))) This is how you can use the Demo setup: sql> import Demo
sql> demoAllAnalyses "SELECT * FROM foo"
Tables accessed:
public.foo
Columns accessed by clause:
public.foo.a SELECT
public.foo.b SELECT
public.foo.c SELECT
Joins:
no joins
Table lineage:
no tables modified This depends on the content of the demo folder. There is for example a catalog setup that has some tables: -- and construct a catalog, with tables `foo` (columns a, b, and c) and `bar` (columns x, y, and z)
catalog :: Catalog
catalog = makeDefaultingCatalog catalogMap [defaultSchema] defaultDatabase
where
defaultDatabase :: DatabaseName ()
defaultDatabase = DatabaseName () "defaultDatabase"
defaultSchema :: UQSchemaName ()
defaultSchema = mkNormalSchema "public" ()
foo :: (UQTableName (), SchemaMember)
foo = ( QTableName () None "foo", persistentTable [ QColumnName () None "a"
, QColumnName () None "b"
, QColumnName () None "c"
] )
bar :: (UQTableName (), SchemaMember)
bar = ( QTableName () None "bar", persistentTable [ QColumnName () None "x"
, QColumnName () None "y"
, QColumnName () None "z"
] )
catalogMap :: CatalogMap
catalogMap = HMS.singleton defaultDatabase $
HMS.fromList [ ( defaultSchema, HMS.fromList [ foo , bar ] ) ]
|
Hi,
How can I run queryparser not with stack ghci ?
In which way can I run it with cmd ? Receiving query file as input and file name to output ?
How can we make it more generic that it is not using stack ghci.
Can you kindly please provide us some examples ?
Sorry I'm not families with stack or Haskall at all.
The text was updated successfully, but these errors were encountered: