OmniSciDB  340b00dbf6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OmniSciOptionsMap.java
Go to the documentation of this file.
1 package com.mapd.parser.extension.ddl.omnisci;
2 
3 import org.apache.calcite.runtime.CalciteException;
4 import org.apache.calcite.sql.SqlLiteral;
5 import org.apache.calcite.sql.SqlNode;
6 import org.apache.calcite.sql.type.SqlTypeName;
7 
8 import java.util.HashMap;
9 
10 public class OmniSciOptionsMap extends HashMap<String, Object> {
11  static public void add(OmniSciOptionsMap map, String key, SqlNode value) {
12  if (value instanceof SqlLiteral) {
13  SqlLiteral literalValue = (SqlLiteral) value;
14  if (SqlTypeName.STRING_TYPES.contains(literalValue.getTypeName())) {
15  map.put(key, ((SqlLiteral) value).getValueAs(String.class));
16  } else {
17  map.put(key, ((SqlLiteral) value).getValue());
18  }
19  } else {
20  throw new CalciteException("Unsupported with value type for value : `"
21  + value.toString() + "` (option : `" + key + "`)",
22  null);
23  }
24  }
25 }
static void add(OmniSciOptionsMap map, String key, SqlNode value)