OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CustomExpression.h
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 #pragma once
18 
19 #include <string>
20 
21 namespace Catalog_Namespace {
22 enum class DataSourceType { TABLE = 0 };
23 
25  CustomExpression(const std::string& name,
26  const std::string& expression_json,
28  int32_t data_source_id)
29  : name(name)
30  , expression_json(expression_json)
31  , data_source_type(data_source_type)
32  , data_source_id(data_source_id) {}
33 
34  CustomExpression(int32_t id,
35  const std::string& name,
36  const std::string& expression_json,
38  int32_t data_source_id,
39  bool is_deleted)
40  : id(id)
41  , name(name)
42  , expression_json(expression_json)
43  , data_source_type(data_source_type)
44  , data_source_id(data_source_id)
45  , is_deleted(is_deleted) {}
46 
47  static std::string dataSourceTypeToString(DataSourceType type_enum) {
48  // Only table data source type is currently supported
49  CHECK(type_enum == DataSourceType::TABLE)
50  << "Unexpected data source type: " << static_cast<int>(type_enum);
51  return "TABLE";
52  }
53 
54  static DataSourceType dataSourceTypeFromString(const std::string& type_str) {
55  // Only table data source type is currently supported
56  CHECK_EQ(type_str, "TABLE");
57  return DataSourceType::TABLE;
58  }
59 
60  int32_t id{-1};
61  std::string name;
62  std::string expression_json;
64  int32_t data_source_id{-1};
65  bool is_deleted{false};
66 };
67 } // namespace Catalog_Namespace
#define CHECK_EQ(x, y)
Definition: Logger.h:301
static DataSourceType dataSourceTypeFromString(const std::string &type_str)
CustomExpression(int32_t id, const std::string &name, const std::string &expression_json, DataSourceType data_source_type, int32_t data_source_id, bool is_deleted)
CustomExpression(const std::string &name, const std::string &expression_json, DataSourceType data_source_type, int32_t data_source_id)
static std::string dataSourceTypeToString(DataSourceType type_enum)
#define CHECK(condition)
Definition: Logger.h:291