typos fixed

This commit is contained in:
VaclavT 2021-08-14 17:30:24 +02:00
parent fc0ce36e8d
commit efb4ee1648
7 changed files with 17 additions and 10 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ cmake-build-debug
tmp/.idea
Makefile
localhost.session.sql
CMakeFiles

View File

@ -1,7 +1,10 @@
### TODO
- default double shoud have 2 decimal points (use set)
- support for select col as ALIAS
- date functions - now, add_date...
- string functions rtrim, ltrim, rpad, lpad
- round function
- add pipe | concatenation
- support for order by, offset, limit (allow column name in order by, validate)
- command line interface
@ -10,3 +13,4 @@
- add count min and max functions, eg aggregate functions
- add const wherever should be
- PERF in Row::Row(const Row &other), could be more efficient (memory and cpu)
- use references where pointer cannot be nullptr

View File

@ -130,14 +130,14 @@ void debug() {
// "create table ticker ( tablee varchar(5) not null, permaticker integer, ticker varchar(10) not null, name varchar(256) not null, exchange varchar(32), isdelisted boolean, category varchar(32), cusips varchar(256), siccode integer, sicsector varchar(256), sicindustry varchar(256), famasector varchar(256), famaindustry varchar(256), sector varchar(128), industry varchar(128), scalemarketcap varchar(64), scalerevenue varchar(64), relatedtickers varchar(128), currency varchar(3), location varchar(64), lastupdated date, firstadded date, firstpricedate date, lastpricedate date, firstquarter date, lastquarter date, secfilings varchar(256), companysite varchar(256))",
// "load ticker from '/Users/vaclavt/Library/Mobile Documents/com~apple~CloudDocs/Development/usql/tickers.csv')",
// "select * from ticker where ticker = 'WFC' and tablee = 'SF1'",
"set 'DATE_FORMAT' = '%Y-%m-%d'",
"show 'DATE_FORMAT'",
"create table sf1 ( ticker varchar(8), dimension varchar(3), calendar_date date, date_key date, report_period date, last_updated date, accoci float, assets float, assetsavg float, assetsc float, assetsnc float, assetturnover float, bvps float, capex float, cashneq float, cashnequsd float, cor float, consolinc float, currentratio float, de float, debt float, debtc float, debtnc float, debtusd float, deferredrev float, depamor float, deposits float, divyield float, dps float, ebit float, ebitda float, ebitdamargin float, ebitdausd float, ebitusd float, ebt float, eps float, epsdil float, epsusd float, equity float, equityavg float, equityusd float, ev float, evebit float, evebitda float, fcf float, fcfps float, fxusd float, gp float, grossmargin float, intangibles float, intexp float, invcap float, invcapavg float, inventory float, investments float, investmentsc float, investmentsnc float, liabilities float, liabilitiesc float, liabilitiesnc float, marketcap float, ncf float, ncfbus float, ncfcommon float, ncfdebt float, ncfdiv float, ncff float, ncfi float, ncfinv float, ncfo float, ncfx float, netinc float, netinccmn float, netinccmnusd float, netincdis float, netincnci float, netmargin float, opex float, opinc float, payables float, payoutratio float, pb float, pe float, pe1 float, ppnenet float, prefdivis float, price float, ps float, ps1 float, receivables float, retearn float, revenue float, revenueusd float, rnd float, roa float, roe float, roic float, ros float, sbcomp float, sgna float, sharefactor float, sharesbas float, shareswa float, shareswadil float, sps float, tangibles float, taxassets float, taxexp float, taxliabilities float, tbvps float, workingcapital float)",
"load sf1 from '/tmp/sf1.csv')",
// "set 'DATE_FORMAT' = '%Y-%m-%d'",
// "show 'DATE_FORMAT'",
// "create table sf1 ( ticker varchar(8), dimension varchar(3), calendar_date date, date_key date, report_period date, last_updated date, accoci float, assets float, assetsavg float, assetsc float, assetsnc float, assetturnover float, bvps float, capex float, cashneq float, cashnequsd float, cor float, consolinc float, currentratio float, de float, debt float, debtc float, debtnc float, debtusd float, deferredrev float, depamor float, deposits float, divyield float, dps float, ebit float, ebitda float, ebitdamargin float, ebitdausd float, ebitusd float, ebt float, eps float, epsdil float, epsusd float, equity float, equityavg float, equityusd float, ev float, evebit float, evebitda float, fcf float, fcfps float, fxusd float, gp float, grossmargin float, intangibles float, intexp float, invcap float, invcapavg float, inventory float, investments float, investmentsc float, investmentsnc float, liabilities float, liabilitiesc float, liabilitiesnc float, marketcap float, ncf float, ncfbus float, ncfcommon float, ncfdebt float, ncfdiv float, ncff float, ncfi float, ncfinv float, ncfo float, ncfx float, netinc float, netinccmn float, netinccmnusd float, netincdis float, netincnci float, netmargin float, opex float, opinc float, payables float, payoutratio float, pb float, pe float, pe1 float, ppnenet float, prefdivis float, price float, ps float, ps1 float, receivables float, retearn float, revenue float, revenueusd float, rnd float, roa float, roe float, roic float, ros float, sbcomp float, sgna float, sharefactor float, sharesbas float, shareswa float, shareswadil float, sps float, tangibles float, taxassets float, taxexp float, taxliabilities float, tbvps float, workingcapital float)",
// "load sf1 from '/tmp/sf1.csv'",
// "select * from sf1 where ticker = 'WFC'",
// "select ticker, dimension, calendar_date, eps, dps from sf1 where (ticker = 'AIG' or ticker = 'AI') and dimension = 'MRY' order by 3 desc",
// "select ticker, dimension, calendar_date, eps, dps from sf1 where (ticker = 'AIG' or ticker = 'AI') and (dimension = 'MRY' or dimension = 'MRQ') order by 3 desc",
"select ticker, dimension, calendar_date, eps, dps from sf1 where (ticker = 'AIG' or ticker = 'WFC') and dimension = 'MRY' order by 3 desc",
// "select ticker, dimension, calendar_date, eps, dps from sf1 where (ticker = 'AIG' or ticker = 'WFC') and dimension = 'MRY' order by 3 desc",
"create table a (i integer not null, s varchar(64), f float null, d date null, b boolean)",
"insert into a (i, s, b) values(1, upper('one'), 'Y')",
"insert into a (i, s, b) values(1 + 10000, upper('one'), 'Y')",
@ -200,9 +200,9 @@ void debug() {
int main(int argc, char *argv[]) {
debug();
//debug();
// repl();
repl();
return 0;
}

View File

@ -425,7 +425,7 @@ namespace usql {
std::unique_ptr<Node> Parser::parse_value() {
auto token_type = m_lexer.tokenType();
// parenthised expression
// parenthesised expression
if (token_type == TokenType::open_paren) {
m_lexer.skipToken(TokenType::open_paren);

View File

@ -95,7 +95,7 @@ namespace usql {
};
struct FunctionNode : Node {
std::string function;
std::string function; // TODO use enum
std::vector<std::unique_ptr<Node>> params;
FunctionNode(const std::string func_name, std::vector<std::unique_ptr<Node>> pars) :

View File

@ -24,11 +24,12 @@ Table::Table(const Table &other) {
ColDefNode Table::get_column_def(const std::string &col_name) {
auto name_cmp = [col_name](const ColDefNode& cd) { return cd.name == col_name; };
auto col_def = std::find_if(begin(m_col_defs), end(m_col_defs), name_cmp);
if (col_def != std::end(m_col_defs)) {
return *col_def;
} else {
throw Exception("column not exists (" + col_name + ")");
throw Exception("column does not exist (" + col_name + ")");
}
}

1
usql.h
View File

@ -48,6 +48,7 @@ private:
static std::unique_ptr<Table> create_stmt_result_table(long code, const std::string &text, size_t affected_rows);
static std::tuple<int, ColDefNode> get_column_definition(Table *table, SelectColNode *select_col_node, int col_order) ;
static std::tuple<int, ColDefNode> get_column_definition2(Table *table, Node *select_col_node, const std::string & col_name, int col_order) ;
Table *find_table(const std::string &name);
void check_table_not_exists(const std::string &name);