OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RangeTableEntry.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, 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,
60  catalog.getDatabaseId(), table_desc->tableId, col_desc->columnId},
61  rte_idx);
62  auto tle = std::make_shared<TargetEntry>(col_desc->columnName, cv, false);
63  tlist.push_back(tle);
64  }
65 }
66 
68  const Catalog_Namespace::Catalog& catalog,
69  const std::string& name) {
70  for (auto cd : column_descs) {
71  if (cd->columnName == name) {
72  return cd;
73  }
74  }
75  const ColumnDescriptor* cd = catalog.getMetadataForColumn(table_desc->tableId, name);
76  if (cd != nullptr) {
77  column_descs.push_back(cd);
78  }
79  return cd;
80 }
81 
82 } // 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:143
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
int getDatabaseId() const
Definition: Catalog.h:326
specifies the content in-memory of a row in the column metadata table
const TableDescriptor * get_table_desc() const
const std::list< const ColumnDescriptor * > & get_column_descs() const
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:2172
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)
string name
Definition: setup.in.py:72