Skip to content

Commit 2590612

Browse files
committed
adding const qualifier to methos/variables; as part of this effort the /reolve_name/ of functions is now done upon semnatic phase before execution; semantic phase should be more the name-resolving(will be on later phase); [ #42 ]
Signed-off-by: gal salomon <[email protected]>
1 parent 051a52f commit 2590612

File tree

3 files changed

+144
-141
lines changed

3 files changed

+144
-141
lines changed

include/s3select.h

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,6 @@ class s3select_projections
3030
std::vector<base_statement*> m_projections;
3131

3232
public:
33-
bool is_aggregate()
34-
{
35-
//TODO iterate on projections , and search for aggregate
36-
//for(auto p : m_projections){}
37-
38-
return false;
39-
}
40-
41-
bool semantic()
42-
{
43-
//TODO check aggragtion function are not nested
44-
return false;
45-
}
4633

4734
std::vector<base_statement*>* get()
4835
{
@@ -71,7 +58,6 @@ struct actionQ
7158
std::vector<std::string> trimTypeQ;
7259
projection_alias alias_map;
7360
std::string from_clause;
74-
std::vector<std::string> schema_columns;
7561
s3select_projections projections;
7662

7763
uint64_t in_set_count;
@@ -80,28 +66,28 @@ struct actionQ
8066

8167
actionQ():in_set_count(0), when_than_count(0){}
8268

83-
std::map<void*,std::vector<char*> *> x_map;
69+
std::map<const void*,std::vector<const char*> *> x_map;
8470

8571
~actionQ()
8672
{
8773
for(auto m : x_map)
8874
delete m.second;
8975
}
9076

91-
bool is_already_scanned(void *th,char *a)
77+
bool is_already_scanned(const void *th,const char *a)
9278
{
9379
//purpose: caller get indication in the case a specific builder is scan more than once the same text(pointer)
9480
auto t = x_map.find(th);
9581

9682
if(t == x_map.end())
9783
{
98-
auto v = new std::vector<char*>;//TODO delete
99-
x_map.insert(std::pair<void*,std::vector<char*> *>(th,v));
84+
auto v = new std::vector<const char*>;//TODO delete
85+
x_map.insert(std::pair<const void*,std::vector<const char*> *>(th,v));
10086
v->push_back(a);
10187
}
10288
else
10389
{
104-
for( auto c : *(t->second) )
90+
for(auto& c : *(t->second))
10591
{
10692
if( strcmp(c,a) == 0)
10793
return true;
@@ -384,7 +370,9 @@ struct s3select : public bsc::grammar<s3select>
384370
int semantic()
385371
{
386372
for (const auto &e : get_projections_list())
387-
{//upon validate there is no aggregation-function nested calls, it validates legit aggregation call.
373+
{
374+
e->resolve_node();
375+
//upon validate there is no aggregation-function nested calls, it validates legit aggregation call.
388376
if (e->is_nested_aggregate(aggr_flow))
389377
{
390378
error_description = "nested aggregation function is illegal i.e. sum(...sum ...)";
@@ -410,7 +398,7 @@ struct s3select : public bsc::grammar<s3select>
410398
//in case projection column is not aggregate, the projection column must *not* contain reference to columns.
411399
if(e->is_column_reference())
412400
{
413-
error_description = "illegal expression. /select sum(c1) + c1 ..../ is not allow type of query";
401+
error_description = "illegal query; projection contains aggregation function is not allowed with projection contains column reference";
414402
throw base_s3select_exception(error_description, base_s3select_exception::s3select_exp_en_t::FATAL);
415403
}
416404
}
@@ -1453,7 +1441,7 @@ class csv_object : public base_s3object
14531441
m_where_clause->traverse_and_apply(m_sa, m_s3_select->get_aliases());
14541442
}
14551443

1456-
for (auto p : m_projections)
1444+
for (auto& p : m_projections)
14571445
{
14581446
p->traverse_and_apply(m_sa, m_s3_select->get_aliases());
14591447
}

0 commit comments

Comments
 (0)