1
Fork 0

update website

This commit is contained in:
Jake Wheat 2024-01-10 12:54:01 +00:00
parent 2fd285e670
commit 0460c237e5
3 changed files with 157 additions and 107 deletions

4
TODO
View file

@ -1,3 +1,7 @@
This file is completely out of date.
----
medium tasks next release medium tasks next release
review alters, and think about adding rename versions review alters, and think about adding rename versions

View file

@ -15,7 +15,6 @@ import Language.SQL.SimpleSQL.Parse
import Language.SQL.SimpleSQL.Syntax (Statement) import Language.SQL.SimpleSQL.Syntax (Statement)
import qualified Data.Text as T import qualified Data.Text as T
main :: IO () main :: IO ()
main = do main = do
args <- getArgs args <- getArgs

View file

@ -94,13 +94,27 @@ Parsed AST:
[source,haskell] [source,haskell]
---- ----
Select{qeSetQuantifier = All, Select
qeSelectList = { qeSetQuantifier = SQDefault
[(BinOp (Iden (Name "a")) (Name "+") , qeSelectList =
(BinOp (Iden (Name "b")) (Name "*") (Iden (Name "c"))), [ ( BinOp
Nothing)], (Iden [ Name Nothing "a" ])
qeFrom = [], qeWhere = Nothing, qeGroupBy = [], qeHaving = Nothing, [ Name Nothing "+" ]
qeOrderBy = [], qeOffset = Nothing, qeFetchFirst = Nothing} (BinOp
(Iden [ Name Nothing "b" ])
[ Name Nothing "*" ]
(Iden [ Name Nothing "c" ]))
, Nothing
)
]
, qeFrom = []
, qeWhere = Nothing
, qeGroupBy = []
, qeHaving = Nothing
, qeOrderBy = []
, qeOffset = Nothing
, qeFetchFirst = Nothing
}
---- ----
TPC-H query 21: TPC-H query 21:
@ -153,16 +167,25 @@ Parsed:
[source,haskell] [source,haskell]
---- ----
Select{qeSetQuantifier = All, Select
qeSelectList = { qeSetQuantifier = SQDefault
[(Iden (Name "s_name"), Nothing), , qeSelectList =
(App (Name "count") [Star], Just (Name "numwait"))], [ ( Iden [ Name Nothing "s_name" ] , Nothing )
qeFrom = , ( App [ Name Nothing "count" ] [ Star ]
[TRSimple (Name "supplier"), , Just (Name Nothing "numwait")
TRAlias (TRSimple (Name "lineitem")) (Alias (Name "l1") Nothing), )
TRSimple (Name "orders"), TRSimple (Name "nation")], ]
qeWhere = , qeFrom =
Just [ TRSimple [ Name Nothing "supplier" ]
, TRAlias
(TRSimple [ Name Nothing "lineitem" ])
(Alias (Name Nothing "l1") Nothing)
, TRSimple [ Name Nothing "orders" ]
, TRSimple [ Name Nothing "nation" ]
]
, qeWhere =
Just
(BinOp
(BinOp (BinOp
(BinOp (BinOp
(BinOp (BinOp
@ -170,90 +193,113 @@ Select{qeSetQuantifier = All,
(BinOp (BinOp
(BinOp (BinOp
(BinOp (BinOp
(BinOp (Iden (Name "s_suppkey")) (Name "=") (Iden [ Name Nothing "s_suppkey" ])
(BinOp (Iden (Name "l1")) (Name ".") [ Name Nothing "=" ]
(Iden (Name "l_suppkey")))) (Iden [ Name Nothing "l1" , Name Nothing "l_suppkey" ]))
(Name "and") [ Name Nothing "and" ]
(BinOp (Iden (Name "o_orderkey")) (Name "=") (BinOp
(BinOp (Iden (Name "l1")) (Name ".") (Iden [ Name Nothing "o_orderkey" ])
(Iden (Name "l_orderkey"))))) [ Name Nothing "=" ]
(Name "and") (Iden [ Name Nothing "l1" , Name Nothing "l_orderkey" ])))
(BinOp (Iden (Name "o_orderstatus")) (Name "=") (StringLit "F"))) [ Name Nothing "and" ]
(Name "and")
(BinOp (BinOp
(BinOp (Iden (Name "l1")) (Name ".") (Iden (Name "l_receiptdate"))) (Iden [ Name Nothing "o_orderstatus" ])
(Name ">") [ Name Nothing "=" ]
(BinOp (Iden (Name "l1")) (Name ".") (StringLit "'" "'" "F")))
(Iden (Name "l_commitdate"))))) [ Name Nothing "and" ]
(Name "and") (BinOp
(SubQueryExpr SqExists (Iden [ Name Nothing "l1" , Name Nothing "l_receiptdate" ])
(Select{qeSetQuantifier = All, qeSelectList = [(Star, Nothing)], [ Name Nothing ">" ]
qeFrom = (Iden [ Name Nothing "l1" , Name Nothing "l_commitdate" ])))
[TRAlias (TRSimple (Name "lineitem")) [ Name Nothing "and" ]
(Alias (Name "l2") Nothing)], (SubQueryExpr
qeWhere = SqExists
Just Select
(BinOp { qeSetQuantifier = SQDefault
(BinOp , qeSelectList = [ ( Star , Nothing ) ]
(BinOp (Iden (Name "l2")) (Name ".") , qeFrom =
(Iden (Name "l_orderkey"))) [ TRAlias
(Name "=") (TRSimple [ Name Nothing "lineitem" ])
(BinOp (Iden (Name "l1")) (Name ".") (Alias (Name Nothing "l2") Nothing)
(Iden (Name "l_orderkey")))) ]
(Name "and") , qeWhere =
(BinOp Just
(BinOp (Iden (Name "l2")) (Name ".") (BinOp
(Iden (Name "l_suppkey"))) (BinOp
(Name "<>") (Iden [ Name Nothing "l2" , Name Nothing "l_orderkey" ])
(BinOp (Iden (Name "l1")) (Name ".") [ Name Nothing "=" ]
(Iden (Name "l_suppkey"))))), (Iden [ Name Nothing "l1" , Name Nothing "l_orderkey" ]))
qeGroupBy = [], qeHaving = Nothing, qeOrderBy = [], [ Name Nothing "and" ]
qeOffset = Nothing, qeFetchFirst = Nothing}))) (BinOp
(Name "and") (Iden [ Name Nothing "l2" , Name Nothing "l_suppkey" ])
(PrefixOp (Name "not") [ Name Nothing "<>" ]
(SubQueryExpr SqExists (Iden [ Name Nothing "l1" , Name Nothing "l_suppkey" ])))
(Select{qeSetQuantifier = All, qeSelectList = [(Star, Nothing)], , qeGroupBy = []
qeFrom = , qeHaving = Nothing
[TRAlias (TRSimple (Name "lineitem")) , qeOrderBy = []
(Alias (Name "l3") Nothing)], , qeOffset = Nothing
qeWhere = , qeFetchFirst = Nothing
Just }))
(BinOp [ Name Nothing "and" ]
(BinOp (PrefixOp
(BinOp [ Name Nothing "not" ]
(BinOp (Iden (Name "l3")) (Name ".") (SubQueryExpr
(Iden (Name "l_orderkey"))) SqExists
(Name "=") Select
(BinOp (Iden (Name "l1")) (Name ".") { qeSetQuantifier = SQDefault
(Iden (Name "l_orderkey")))) , qeSelectList = [ ( Star , Nothing ) ]
(Name "and") , qeFrom =
(BinOp [ TRAlias
(BinOp (Iden (Name "l3")) (Name ".") (TRSimple [ Name Nothing "lineitem" ])
(Iden (Name "l_suppkey"))) (Alias (Name Nothing "l3") Nothing)
(Name "<>") ]
(BinOp (Iden (Name "l1")) (Name ".") , qeWhere =
(Iden (Name "l_suppkey"))))) Just
(Name "and") (BinOp
(BinOp (BinOp
(BinOp (Iden (Name "l3")) (Name ".") (BinOp
(Iden (Name "l_receiptdate"))) (Iden [ Name Nothing "l3" , Name Nothing "l_orderkey" ])
(Name ">") [ Name Nothing "=" ]
(BinOp (Iden (Name "l3")) (Name ".") (Iden
(Iden (Name "l_commitdate"))))), [ Name Nothing "l1" , Name Nothing "l_orderkey" ]))
qeGroupBy = [], qeHaving = Nothing, qeOrderBy = [], [ Name Nothing "and" ]
qeOffset = Nothing, qeFetchFirst = Nothing})))) (BinOp
(Name "and") (Iden [ Name Nothing "l3" , Name Nothing "l_suppkey" ])
(BinOp (Iden (Name "s_nationkey")) (Name "=") [ Name Nothing "<>" ]
(Iden (Name "n_nationkey")))) (Iden
(Name "and") [ Name Nothing "l1" , Name Nothing "l_suppkey" ])))
(BinOp (Iden (Name "n_name")) (Name "=") (StringLit "INDIA"))), [ Name Nothing "and" ]
qeGroupBy = [SimpleGroup (Iden (Name "s_name"))], (BinOp
qeHaving = Nothing, (Iden [ Name Nothing "l3" , Name Nothing "l_receiptdate" ])
qeOrderBy = [ Name Nothing ">" ]
[SortSpec (Iden (Name "numwait")) Desc NullsOrderDefault, (Iden
SortSpec (Iden (Name "s_name")) Asc NullsOrderDefault], [ Name Nothing "l3" , Name Nothing "l_commitdate" ])))
qeOffset = Nothing, qeFetchFirst = Just (NumLit "100")}) , qeGroupBy = []
, qeHaving = Nothing
, qeOrderBy = []
, qeOffset = Nothing
, qeFetchFirst = Nothing
})))
[ Name Nothing "and" ]
(BinOp
(Iden [ Name Nothing "s_nationkey" ])
[ Name Nothing "=" ]
(Iden [ Name Nothing "n_nationkey" ])))
[ Name Nothing "and" ]
(BinOp
(Iden [ Name Nothing "n_name" ])
[ Name Nothing "=" ]
(StringLit "'" "'" "INDIA")))
, qeGroupBy = [ SimpleGroup (Iden [ Name Nothing "s_name" ]) ]
, qeHaving = Nothing
, qeOrderBy =
[ SortSpec (Iden [ Name Nothing "numwait" ]) Desc NullsOrderDefault
, SortSpec
(Iden [ Name Nothing "s_name" ]) DirDefault NullsOrderDefault
]
, qeOffset = Nothing
, qeFetchFirst = Just (NumLit "100")
}
---- ----
@ -290,7 +336,7 @@ Parsing some SQL and printing the AST:
[source,haskell] [source,haskell]
---- ----
{-# LANGUAGE OverloadedStrings #-}
import System.Environment import System.Environment
import Text.Show.Pretty import Text.Show.Pretty
import System.IO import System.IO
@ -298,10 +344,11 @@ import System.IO
import Language.SQL.SimpleSQL.Parse import Language.SQL.SimpleSQL.Parse
(parseStatements (parseStatements
,ParseError ,ParseError
,peFormattedError) ,prettyError
,ansi2011)
import Language.SQL.SimpleSQL.Syntax (ansi2011, Statement)
import Language.SQL.SimpleSQL.Syntax (Statement)
import qualified Data.Text as T
main :: IO () main :: IO ()
main = do main = do
@ -331,8 +378,8 @@ main = do
doIt :: String -> IO () doIt :: String -> IO ()
doIt src = do doIt src = do
let parsed :: Either ParseError [Statement] let parsed :: Either ParseError [Statement]
parsed = parseStatements ansi2011 "" Nothing src parsed = parseStatements ansi2011 "" Nothing (T.pack src)
either (error . peFormattedError) either (error . T.unpack . prettyError)
(putStrLn . ppShow) (putStrLn . ppShow)
parsed parsed
---- ----