OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RangeTableEntry.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2019 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "RangeTableEntry.h"
18 
19 #include <Catalog/Catalog.h>
20 
21 namespace Analyzer {
22 
24  if (view_query != nullptr) {
25  delete view_query;
26  }
27 }
28 
29 const std::list<const ColumnDescriptor*>& RangeTableEntry::get_column_descs() const {
30  return column_descs;
31 }
32 
34  return table_desc->tableId;
35 }
36 
37 const std::string& RangeTableEntry::get_table_name() const {
38  return table_desc->tableName;
39 }
40 
42  return table_desc;
43 }
44 
46  column_descs =
47  catalog.getAllColumnMetadataForTable(table_desc->tableId, true, true, true);
48 }
49 
51  const Catalog_Namespace::Catalog& catalog,
52  std::vector<std::shared_ptr<TargetEntry>>& tlist,
53  int rte_idx) {
54  column_descs =
55  catalog.getAllColumnMetadataForTable(table_desc->tableId, false, true, true);
56  for (auto col_desc : column_descs) {
57  auto cv = makeExpr<ColumnVar>(
58  col_desc->columnType, table_desc->tableId, col_desc->columnId, rte_idx);
59  auto tle = std::make_shared<TargetEntry>(col_desc->columnName, cv, false);
60  tlist.push_back(tle);
61  }
62 }
63 
65  const Catalog_Namespace::Catalog& catalog,
66  const std::string& name) {
67  for (auto cd : column_descs) {
68  if (cd->columnName == name) {
69  return cd;
70  }
71  }
72  const ColumnDescriptor* cd = catalog.getMetadataForColumn(table_desc->tableId, name);
73  if (cd != nullptr) {
74  column_descs.push_back(cd);
75  }
76  return cd;
77 }
78 
79 } // namespace Analyzer
void add_all_column_descs(const Catalog_Namespace::Catalog &catalog)
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:81
std::string tableName
Query * view_query
void expand_star_in_targetlist(const Catalog_Namespace::Catalog &catalog, std::vector< std::shared_ptr< TargetEntry >> &tlist, int rte_idx)
virtual ~RangeTableEntry()
std::list< const ColumnDescriptor * > column_descs
int32_t get_table_id() const
This file contains the class specification and related data structures for Catalog.
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
specifies the content in-memory of a row in the column metadata table
std::list< const ColumnDescriptor * > getAllColumnMetadataForTable(const int tableId, const bool fetchSystemColumns, const bool fetchVirtualColumns, const bool fetchPhysicalColumns) const
Returns a list of pointers to constant ColumnDescriptor structs for all the columns from a particular...
Definition: Catalog.cpp:1581
const TableDescriptor * get_table_desc() const
const std::list< const ColumnDescriptor * > & get_column_descs() const
const std::string & get_table_name() const
const TableDescriptor * table_desc
const ColumnDescriptor * get_column_desc(const Catalog_Namespace::Catalog &catalog, const std::string &name)
specifies the content in-memory of a row in the table metadata table