OmniSciDB  bf83d84833
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Go to the documentation of this file.
1 /*
2  * Copyright 2020 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  *
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  */
17 #pragma once
19 #include "Catalog/Catalog.h"
20 #include "Shared/sqltypes.h"
22 namespace ddl_utils {
23 class SqlType {
24  public:
40  SqlType(SQLTypes type, int param1, int param2, bool is_array, int array_size);
42  virtual SQLTypes get_type() const;
43  virtual int get_param1() const;
44  virtual void set_param1(int param);
45  virtual int get_param2() const;
46  virtual bool get_is_array() const;
47  virtual void set_is_array(bool a);
48  virtual int get_array_size() const;
49  virtual void set_array_size(int s);
50  virtual std::string to_string() const;
51  virtual void check_type();
53  protected:
55  int param1; // e.g. for NUMERIC(10). -1 means unspecified.
56  int param2; // e.g. for NUMERIC(10,3). 0 is default value.
57  bool is_array;
59 };
61 class Encoding {
62  public:
69  Encoding(std::string* encoding_name, int encoding_param);
70  virtual ~Encoding() {}
72  virtual const std::string* get_encoding_name() const;
73  virtual int get_encoding_param() const;
75  protected:
76  std::unique_ptr<std::string> encoding_name;
78 };
80 enum class DataTransferType { IMPORT = 1, EXPORT };
83  public:
84  static void initializeFromConfigFile(const std::string& server_config_path);
85  static void validateWhitelistedFilePath(
86  const std::vector<std::string>& expanded_file_paths,
87  const DataTransferType data_transfer_type);
88  static void clear();
90  private:
91  static std::vector<std::string> whitelisted_import_paths_;
92  static std::vector<std::string> whitelisted_export_paths_;
93 };
96  public:
97  static void addToBlacklist(const std::string& path);
98  static bool isBlacklistedPath(const std::string& path);
99  static void clear();
101  private:
102  static std::vector<std::string> blacklisted_paths_;
103 };
105 enum class TableType { TABLE = 1, VIEW, FOREIGN_TABLE };
110  int encoding_size,
111  const SqlType* column_type);
113 void validate_and_set_dictionary_encoding(ColumnDescriptor& cd, int encoding_size);
117 void validate_and_set_sparse_encoding(ColumnDescriptor& cd, int encoding_size);
119 void validate_and_set_compressed_encoding(ColumnDescriptor& cd, int encoding_size);
121 void validate_and_set_date_encoding(ColumnDescriptor& cd, int encoding_size);
124  const Encoding* encoding,
125  const SqlType* column_type);
127 void validate_and_set_type(ColumnDescriptor& cd, SqlType* column_type);
129 void validate_and_set_array_size(ColumnDescriptor& cd, const SqlType* column_type);
131 void set_column_descriptor(const std::string& column_name,
132  ColumnDescriptor& cd,
133  SqlType* column_type,
134  const bool not_null,
135  const Encoding* encoding);
137 void set_default_table_attributes(const std::string& table_name,
138  TableDescriptor& td,
139  const int32_t column_count);
141 void validate_non_duplicate_column(const std::string& column_name,
142  std::unordered_set<std::string>& upper_column_names);
144 void validate_non_reserved_keyword(const std::string& column_name);
146 void validate_table_type(const TableDescriptor* td,
147  const TableType expected_table_type,
148  const std::string& command);
150 std::string table_type_enum_to_string(const TableType table_type);
163 void validate_allowed_file_path(const std::string& file_path,
164  const DataTransferType data_transfer_type,
165  const bool allow_wildcards = false);
166 } // namespace ddl_utils
Definition: DdlUtils.h:80
void validate_and_set_sparse_encoding(ColumnDescriptor &cd, int encoding_size)
Definition: DdlUtils.cpp:361
static std::vector< std::string > whitelisted_export_paths_
Definition: DdlUtils.h:92
Definition: sqltypes.h:37
SqlType(SQLTypes type, int param1, int param2, bool is_array, int array_size)
Definition: DdlUtils.cpp:35
void validate_and_set_array_size(ColumnDescriptor &cd, const SqlType *column_type)
Definition: DdlUtils.cpp:468
virtual void check_type()
Definition: DdlUtils.cpp:150
void validate_and_set_dictionary_encoding(ColumnDescriptor &cd, int encoding_size)
Definition: DdlUtils.cpp:324
static void initializeFromConfigFile(const std::string &server_config_path)
Definition: DdlUtils.cpp:663
virtual int get_encoding_param() const
Definition: DdlUtils.cpp:206
Constants for Builtin SQL Types supported by OmniSci.
void validate_non_duplicate_column(const std::string &column_name, std::unordered_set< std::string > &upper_column_names)
Definition: DdlUtils.cpp:521
void validate_and_set_none_encoding(ColumnDescriptor &cd)
Definition: DdlUtils.cpp:350
This file contains the class specification and related data structures for Catalog.
void validate_and_set_encoding(ColumnDescriptor &cd, const Encoding *encoding, const SqlType *column_type)
Definition: DdlUtils.cpp:413
static std::vector< std::string > whitelisted_import_paths_
Definition: DdlUtils.h:91
static void validateWhitelistedFilePath(const std::vector< std::string > &expanded_file_paths, const DataTransferType data_transfer_type)
Definition: DdlUtils.cpp:696
void set_default_encoding(ColumnDescriptor &cd)
Definition: DdlUtils.cpp:210
SQLTypes type
Definition: DdlUtils.h:54
virtual ~Encoding()
Definition: DdlUtils.h:70
virtual SQLTypes get_type() const
Definition: DdlUtils.cpp:42
virtual std::string to_string() const
Definition: DdlUtils.cpp:74
void validate_non_reserved_keyword(const std::string &column_name)
Definition: DdlUtils.cpp:530
specifies the content in-memory of a row in the column metadata table
void set_default_table_attributes(const std::string &table_name, TableDescriptor &td, const int32_t column_count)
Definition: DdlUtils.cpp:507
void validate_allowed_file_path(const std::string &file_path, const DataTransferType data_transfer_type, const bool allow_wildcards)
Definition: DdlUtils.cpp:613
void set_column_descriptor(const std::string &column_name, ColumnDescriptor &cd, SqlType *column_type, const bool not_null, const Encoding *encoding)
Definition: DdlUtils.cpp:493
void validate_and_set_compressed_encoding(ColumnDescriptor &cd, int encoding_size)
Definition: DdlUtils.cpp:378
virtual const std::string * get_encoding_name() const
Definition: DdlUtils.cpp:202
void validate_and_set_fixed_encoding(ColumnDescriptor &cd, int encoding_size, const SqlType *column_type)
Definition: DdlUtils.cpp:238
std::string table_type_enum_to_string(const TableType table_type)
Definition: DdlUtils.cpp:555
Encoding(std::string *encoding_name, int encoding_param)
Definition: DdlUtils.cpp:199
virtual void set_param1(int param)
Definition: DdlUtils.cpp:50
static bool isBlacklistedPath(const std::string &path)
Definition: DdlUtils.cpp:731
void validate_table_type(const TableDescriptor *td, const TableType expected_table_type, const std::string &command)
Definition: DdlUtils.cpp:538
void validate_and_set_date_encoding(ColumnDescriptor &cd, int encoding_size)
Definition: DdlUtils.cpp:398
static void addToBlacklist(const std::string &path)
Definition: DdlUtils.cpp:726
std::unique_ptr< std::string > encoding_name
Definition: DdlUtils.h:76
virtual void set_is_array(bool a)
Definition: DdlUtils.cpp:62
virtual int get_param1() const
Definition: DdlUtils.cpp:46
virtual int get_param2() const
Definition: DdlUtils.cpp:54
virtual bool get_is_array() const
Definition: DdlUtils.cpp:58
virtual void set_array_size(int s)
Definition: DdlUtils.cpp:70
static std::vector< std::string > blacklisted_paths_
Definition: DdlUtils.h:102
virtual int get_array_size() const
Definition: DdlUtils.cpp:66
void validate_and_set_type(ColumnDescriptor &cd, SqlType *column_type)
Definition: DdlUtils.cpp:449