Kinetica   C#   API  Version 7.2.3.0
KineticaType.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using Avro;
5 using Newtonsoft.Json.Linq;
6 
7 namespace kinetica
8 {
9  public class KineticaType
10  {
11  public class Column
12  {
13  public enum ColumnType
14  {
15  BYTES = Avro.EnumSchema.Type.Bytes,
16  DOUBLE = Avro.EnumSchema.Type.Double,
17  FLOAT = Avro.EnumSchema.Type.Float,
18  INT = Avro.EnumSchema.Type.Int,
19  LONG = Avro.EnumSchema.Type.Long,
20  STRING = Avro.EnumSchema.Type.String,
21  DEFAULT = Avro.EnumSchema.Type.Error
22  };
23 
24  private string m_name;
25  private ColumnType m_type;
26  private bool m_isNullable;
27  private IList<string> m_properties;
28 
35  public Column(string name, ColumnType type, IList<string>? properties = null)
36  {
37  m_name = name;
38  m_type = type;
39  m_isNullable = false;
40  m_properties = properties ?? [];
41 
42  Initialize();
43  }
44 
49  public string getName() { return m_name; }
50 
55  public ColumnType getType() { return m_type; }
56 
61  public bool isNullable() { return m_isNullable; }
62 
67  public IList<string> getProperties() { return m_properties; }
68 
69  internal void setIsNullable( bool val ) { m_isNullable = val; }
70 
75  public string getTypeString()
76  {
77  return m_type switch
78  {
79  ColumnType.BYTES => "bytes",
80  ColumnType.DOUBLE => "double",
81  ColumnType.FLOAT => "float",
82  ColumnType.INT => "int",
83  ColumnType.LONG => "long",
84  ColumnType.STRING => "string",
85  _ => throw new KineticaException("Unsupported column type: " + m_type),
86  };
87  } // end getTypeString()
88 
89  private void Initialize()
90  {
91  if (string.IsNullOrEmpty(m_name))
92  {
93  throw new ArgumentException("Name must not be empty.");
94  }
95 
96  switch (m_type)
97  {
98  case ColumnType.BYTES:
99  case ColumnType.DOUBLE:
100  case ColumnType.FLOAT:
101  case ColumnType.INT:
102  case ColumnType.LONG:
103  case ColumnType.STRING:
104  break;
105 
106  default:
107  throw new ArgumentException($"Column {m_name} must be of type BYTES, DOUBLE, FLOAT, INT, LONG or STRING.");
108  }
109 
110  foreach (var it in m_properties)
111  {
112  if (string.IsNullOrEmpty(it))
113  {
114  throw new ArgumentException("Properties must not be empty.");
115  }
116 
117  if (!m_isNullable && (it == ColumnProperty.NULLABLE))
118  {
119  m_isNullable = true;
120  }
121  }
122  }
123 
124  public override string ToString()
125  {
126  return $"{m_name} ({m_type})";
127  }
128  } // end class Column
129 
130  private class TypeData
131  {
132  public string? label;
133  public IList<Column> columns = [];
134  public Dictionary<string, int> columnMap = [];
135  public string? schemaString = null;
136  public Schema? schema = null;
137  public Type? sourceType = null;
138  }
139 
140  private TypeData m_data = new();
141  private IDictionary<string, IList<string>> m_properties = new Dictionary<string, IList<string>>();
142  private string? m_typeId = null;
143 
150  public static KineticaType fromTable(Kinetica kinetica, string tableName)
151  {
152  var response = kinetica.showTable(tableName);
153  var typeIdCount = response.type_ids.Count;
154 
155  if (typeIdCount == 0)
156  {
157  throw new KineticaException($"Table {tableName} does not exist.");
158  }
159 
160  string typeId = response.type_ids[0];
161  if (typeIdCount > 1)
162  {
163  for (int i = 1; i < typeIdCount; ++i)
164  {
165  if (response.type_ids[i] != typeId)
166  {
167  throw new KineticaException("Table {tableName} is not homogeneous.");
168  }
169  }
170  }
171 
172  return new KineticaType(response.type_labels[0], response.type_schemas[0], response.properties[0], typeId );
173  }
174 
181  public static KineticaType fromTypeID(Kinetica kinetica, string typeId)
182  {
183  var response = kinetica.showTypes(typeId, "");
184 
185  if (response.type_ids.Count < 1)
186  {
187  throw new KineticaException($"Type {typeId} does not exist.");
188  }
189 
190  return new KineticaType(response.labels[0], response.type_schemas[0], response.properties[0]);
191  }
192 
193 
201  public static KineticaType fromDynamicSchema( string dynamicTableSchemaString,
202  Object[] columnHeaders, Object[] columnTypes )
203  {
204  // Make sure that the lists of column names and types are of the same length
205  if ( columnHeaders.Length != columnTypes.Length )
206  throw new KineticaException($"List of column names ({columnHeaders.Length}) and types ({columnTypes.Length}) are not of the same length." );
207 
208  // Parse the schema string so that we can later check if a given column is nullable
209  JObject dynamicSchemaJson;
210  try
211  {
212  dynamicSchemaJson = JObject.Parse( dynamicTableSchemaString );
213  }
214  catch ( Exception ex )
215  {
216  throw new KineticaException( ex.ToString() );
217  }
218 
219  // Create a delegate for checking if a field/column is nullable
220  // ------------------------------------------------------------
221  // The first parameter is the column name, the second is the JSON object
222  var isColumnNullable = new Func<string, JObject, bool>( (columnName, schemaJson) => {
223  // Find the appropriate field
224  bool foundField = false;
225  JToken? fieldList = schemaJson["fields"];
226  if (fieldList != null)
227  {
228  foreach (var field in fieldList)
229  {
230  if ((string?)field["name"] == columnName)
231  {
232  foundField = true; // found it!
233  // Get the type and see if it's a nullable type
234  // (each field is an array of the column type; so need
235  // to extract the type element first)
236  JToken? fieldType = field["type"];
237  if (fieldType != null)
238  {
239  var typeElement = fieldType["items"];
240  if (typeElement == null || typeElement is JValue) // not an array, so can't be nullable
241  return false;
242  // If the type is an array and the second value is 'null', then it's a nullable
243  if ((typeElement is JArray) && ((string)(typeElement as JArray)[1] == "null"))
244  return true;
245  return false;
246  }
247  } // end if
248  } // end foreach
249  }
250  if ( !foundField )
251  throw new KineticaException( $"Could not find the field named '{columnName}'" );
252  return false; // shouldn't ever get here
253  } );
254 
255  // Create appropriate columns and column properties
256  // ------------------------------------------------
257  List<Column> columns = [];
258  Dictionary<string, IList<string>> columnProperties = [];
259  for ( int i = 0; i < columnHeaders.Length; ++i )
260  {
261  // Get the column's name
262  string column_name = (string)columnHeaders[i];
263 
264  // Get the column's type in string format, which might be a property and not a primitive type
265  // (if so, then we'll have to infer the primitive type and save the property)
266  string columnTypeString = (string)columnTypes[i];
267 
268  // Need to create a list for the properties of the column (we'll
269  // extract at most one from the column type)
270  List<string> columnProperty = [];
271 
272  // We need to also infer the primitive type for this column
273  Column.ColumnType columnType;
274 
275  // Infer the type and property from the given 'type'
276  switch ( columnTypeString )
277  {
278  // Primitive type string (and all properties based on it)
279  case "string":
280  columnType = Column.ColumnType.STRING;
281  break;
282 
283  // All properties allowed for the primitive string type
284  case ColumnProperty.CHAR1:
285  case ColumnProperty.CHAR2:
286  case ColumnProperty.CHAR4:
287  case ColumnProperty.CHAR8:
288  case ColumnProperty.CHAR16:
289  case ColumnProperty.CHAR32:
290  case ColumnProperty.CHAR64:
291  case ColumnProperty.CHAR128:
292  case ColumnProperty.CHAR256:
293  case ColumnProperty.DATE:
295  case ColumnProperty.DECIMAL:
296  case ColumnProperty.IPV4:
297  case ColumnProperty.TIME:
298  columnType = Column.ColumnType.STRING;
299  columnProperty.Add( columnTypeString );
300  break;
301 
302  // Primitive type integer
303  case "int":
304  columnType = Column.ColumnType.INT;
305  break;
306 
307  // Properties allowed for the primitive integer type
308  case ColumnProperty.INT8:
309  case ColumnProperty.INT16:
310  columnType = Column.ColumnType.INT;
311  columnProperty.Add( columnTypeString );
312  break;
313 
314  // Primitive type long
315  case "long":
316  columnType = Column.ColumnType.LONG;
317  break;
318 
319  // Properties allowed for the long type
321  columnType = Column.ColumnType.LONG;
322  columnProperty.Add( columnTypeString );
323  break;
324 
325  // Primitive type float
326  case "float":
327  columnType = Column.ColumnType.FLOAT;
328  break;
329 
330  // Primitive type double
331  case "double":
332  columnType = Column.ColumnType.DOUBLE;
333  break;
334 
335  // Primitive type bytes
336  case "bytes":
337  columnType = Column.ColumnType.BYTES;
338  break;
339 
340  default:
341  throw new KineticaException($"Unknown data type/property: {columnTypeString}");
342  } // end switch
343 
344  // Check if the column is nullable (where the column name is "column_#" as returned by Kinetica)
345  if ( isColumnNullable( $"column_{i + 1}", dynamicSchemaJson ) )
346  columnProperty.Add( ColumnProperty.NULLABLE );
347 
348  // Now that we have the name, the type and potentially a property for the column,
349  // create a Column type and add it to the list
350  Column column = new( column_name, columnType, columnProperty );
351  columns.Add( column );
352 
353  // Also, save the column property in the column name->property map
354  columnProperties.Add( column_name, columnProperty );
355  } // end looping over column headers and types
356 
357 
358  // Create and return the KineticaType object based on the columns and properties
359  return new KineticaType( "", columns, columnProperties );
360  } // end fromDynamicSchema()
361 
362 
363 
379  public static KineticaType fromClass( Type recordClass, IDictionary<string, IList<string>> properties = null )
380  {
381  return fromClass( recordClass, "", properties );
382  } // end fromClass()
383 
384 
394  public static KineticaType fromClass( Type recordClass, string label, IDictionary<string, IList<string>>? properties = null )
395  {
396  // Get the fields in order (******skipping properties inherited from base classes******)
397  // (fields only from this type, i.e. do not include any inherited fields), and public types only
398  System.Reflection.PropertyInfo[] typeProperties = recordClass.GetProperties( System.Reflection.BindingFlags.DeclaredOnly |
399  System.Reflection.BindingFlags.Instance |
400  System.Reflection.BindingFlags.Public );
401 
402  Array.Sort( typeProperties, (p1, p2) => p1.MetadataToken.CompareTo( p2.MetadataToken ) );
403 
404  // Need to have a list of columns
405  List<Column> columns = [];
406  List<string> columnNames = [];
407 
408  // Per property, check that it is one of: int, long, float, double, string, bytes
409  foreach ( var typeProperty in typeProperties )
410  {
411  string columnName = "";
412  Column.ColumnType columnType = Column.ColumnType.DEFAULT;
413  IList<string>? columnProperties = null;
414  bool isColumnNullable = false;
415 
416  // Get the column name
417  columnName = typeProperty.Name;
418 
419  Type? propertyType = typeProperty.PropertyType;
420 
421  // Check if the field is nullable (declared as T? or Nullable<T>)
422  if ( typeProperty.PropertyType.IsGenericType &&
423  ( typeProperty.PropertyType.GetGenericTypeDefinition() == typeof( Nullable<> ) ) )
424  { // the field is a nullable field
425  isColumnNullable = true;
426  // Change the property type to be the underlying type
427  propertyType = Nullable.GetUnderlyingType(propertyType);
428  }
429 
430  // Check the column data type (must be one of int, long, float, double, string, and bytes)
431  if ( propertyType == typeof( System.String ) )
432  {
433  columnType = Column.ColumnType.STRING;
434  }
435  else if ( propertyType == typeof( System.Int32 ) )
436  {
437  columnType = Column.ColumnType.INT;
438  }
439  else if ( propertyType == typeof( System.Int64 ) )
440  {
441  columnType = Column.ColumnType.LONG;
442  }
443  else if ( propertyType == typeof( float ) )
444  {
445  columnType = Column.ColumnType.FLOAT;
446  }
447  else if ( propertyType == typeof( double ) )
448  {
449  columnType = Column.ColumnType.DOUBLE;
450  }
451  else if ( propertyType == typeof( byte ) )
452  {
453  columnType = Column.ColumnType.BYTES;
454  }
455  else
456  throw new KineticaException( "Unsupported data type for " + propertyType?.Name +
457  ": " + propertyType +
458  " (must be one of int, long, float, double, string, and byte)" );
459 
460  // Extract the given column's properties, if any
461  properties?.TryGetValue(columnName, out columnProperties);
462 
463  // Keep a list of the column names for checking the properties
464  columnNames.Add( columnName );
465 
466  // Create the column
467  Column column = new( columnName, columnType, columnProperties );
468  if ( isColumnNullable ) // Set the appropriate nullable flag for the column
469  column.setIsNullable( true );
470 
471  // Save the column
472  columns.Add( column );
473  } // end looping over all members of the class type
474 
475  // Check for extraneous properties
476  if (properties != null)
477  {
478  IEnumerable<string> propertyKeys = properties.Keys;
479  var unknownColumns = propertyKeys.Where(e => !columnNames.Contains(e));
480  // Check if any property is provided for wrong/non-existing columns
481  if (unknownColumns.Any())
482  throw new KineticaException("Properties specified for unknown columns.");
483  }
484  else properties = new Dictionary<string, IList<string>>();
485 
486  // Create the kinetica type
487  KineticaType kType = new(label, columns, properties);
488 
489  // Save the class information in the type
490  kType.saveSourceType( recordClass );
491 
492  return kType;
493  } // end fromClass()
494 
495 
504  public static KineticaType fromObject( Object recordObj, IDictionary<string, IList<string>> properties = null )
505  {
506  return fromObject( recordObj, "", properties );
507  } // end fromObject()
508 
509 
519  public static KineticaType fromObject(Object recordObj, string label = "", IDictionary<string, IList<string>> properties = null)
520  {
521  // Create the type schema from the object
522  // --------------------------------------
523  // Get the class type
524  Type object_type = recordObj.GetType();
525 
526  return fromClass( object_type, label, properties );
527  } // end fromObject()
528 
533  public KineticaType(IList<Column> columns)
534  {
535  m_data.columns = columns;
536  Initialize();
537  CreateSchema(); // create the schema from columns
538  }
539 
545  public KineticaType(string label, IList<Column> columns) : this(columns)
546  {
547  m_data.label = label;
548  }
549 
556  public KineticaType( string label, IList<Column> columns, IDictionary<string, IList<string>> properties ) : this( label, columns )
557  {
558  m_properties = properties ?? new Dictionary<string, IList<string>>();
559  }
560 
565  public KineticaType(string typeSchema)
566  {
567  m_data.schemaString = typeSchema;
568  CreateSchemaFromString( typeSchema );
569  CreateSchema();
570  }
571 
579  public KineticaType(string label, string typeSchema, IDictionary<string, IList<string>> properties, string? typeId = null )
580  {
581  m_properties = properties;
582  m_typeId = typeId;
583  m_data.label = label;
584  m_data.schemaString = typeSchema;
585  CreateSchemaFromString(typeSchema, properties);
586  CreateSchema();
587  }
588 
589  public string getLabel() { return m_data.label; }
590  public IList<Column> getColumns() { return m_data.columns; }
591  public Column getColumn(int index) { return m_data.columns[index]; }
592  public Column getColumn(string name) { return m_data.columns[getColumnIndex(name)]; }
593  public int getColumnCount() { return m_data.columns.Count; }
594  public int getColumnIndex(string name) { return m_data.columnMap[name]; }
595  public bool hasColumn(string name) { return m_data.columnMap.ContainsKey(name); }
596  public Schema getSchema() { return m_data.schema; }
597  public Type? getSourceType() { return m_data.sourceType;}
598  public string getSchemaString() { return m_data.schemaString; }
599  public string getTypeID() { return m_typeId; }
600 
605  public void saveSourceType( Type sourceType )
606  {
607  this.m_data.sourceType = sourceType;
608  } // end saveSourceType
609 
610 
617  public string create(Kinetica kinetica)
618  {
619  // Save the association between this KineticaType's source and itself in the Kinetica object
620  // for future reference (it helps with encoding and decoding records)
621  if ( this.m_data.sourceType != null )
622  kinetica.SetKineticaSourceClassToTypeMapping( this.m_data.sourceType, this );
623 
624  // Register the type with Kinetica
625  CreateTypeResponse response = kinetica.createType( m_data.schemaString, m_data.label, m_properties);
626  return response.type_id;
627  } // end create()
628 
629  private KineticaType() { }
630 
635  private void Initialize()
636  {
637  int columnCount = m_data.columns.Count;
638 
639  if (columnCount == 0)
640  {
641  throw new ArgumentException("At least one column must be specified.");
642  }
643 
644  for (int i = 0; i < columnCount; ++i)
645  {
646  string columnName = m_data.columns[i].getName();
647 
648  if (m_data.columnMap.ContainsKey(columnName))
649  {
650  throw new ArgumentException("Duplicate column name " + columnName + " specified.");
651  }
652 
653  m_data.columnMap[columnName] = i;
654  }
655  } // end Initialize()
656 
657 
663  private void CreateSchemaFromString( string typeSchema,
664  IDictionary<string, IList<string>> properties = null)
665  {
666  // Create the avro schema from the string and save it
667  try
668  {
669  m_data.schema = RecordSchema.Parse(typeSchema);
670  }
671  catch (Exception ex)
672  {
673  throw new KineticaException(ex.ToString());
674  }
675 
676  var root = JObject.Parse(typeSchema);
677 
678  var rootType = root["type"];
679  if ((null == rootType) || !rootType.ToString().Contains("record"))
680  {
681  throw new ArgumentException("Schema must be of type record.");
682  }
683 
684  var fields = root["fields"];
685  if ((null == fields) || !fields.HasValues)
686  {
687  throw new ArgumentException("Schema has no fields.");
688  }
689 
690  foreach (var field in fields)
691  {
692  //if (!field->first.empty() || field->second.empty())
693  //{
694  // throw std::invalid_argument("Schema has invalid field.");
695  //}
696 
697  // Do NOT use ToString 'cause it includes the double quotes (turns it into a JSON representation)
698  string? fieldName = (string?)field["name"];
699  if (string.IsNullOrEmpty(fieldName))
700  {
701  throw new ArgumentException("Schema has unnamed field.");
702  }
703 
704  if (m_data.columnMap.ContainsKey(fieldName))
705  {
706  throw new ArgumentException($"Duplicate field name {fieldName}.");
707  }
708 
709  var fieldType = field["type"];
710  if (null == fieldType)
711  {
712  throw new ArgumentException($"Field {fieldName} has no type.");
713  }
714 
715  // Flag for nullability
716  bool isColumnNullable = false;
717 
718  if (fieldType.HasValues) // If it has children
719  {
720  var fieldTypeArray = fieldType;
721 
722  foreach (var fieldTypeElement in fieldTypeArray.Children())
723  {
724  bool valid = false;
725  //if (fieldTypeElement->first.empty())
726  {
727  var fieldTypeElementString = fieldTypeElement.ToString();
728 
729  if (!string.IsNullOrEmpty(fieldTypeElementString))
730  {
731  if (fieldTypeElementString == "null" || fieldTypeElementString == "\"null\"")
732  {
733  isColumnNullable = true;
734  valid = true;
735  }
736  else //if (fieldType->empty())
737  {
738  fieldType = fieldTypeElement; // fieldTypeElementString;
739  valid = true;
740  }
741  }
742  }
743 
744  if (!valid)
745  {
746  throw new ArgumentException("Field {fieldName} has invalid type.");
747  }
748  }
749  }
750 
751  Column.ColumnType columnType;
752 
753  if (fieldType.ToString().Equals("bytes") || fieldType.ToString().Equals("\"bytes\""))
754  {
755  columnType = Column.ColumnType.BYTES;
756  }
757  else if (fieldType.ToString().Equals("double") || fieldType.ToString().Equals("\"double\""))
758  {
759  columnType = Column.ColumnType.DOUBLE;
760  }
761  else if (fieldType.ToString().Equals("float") || fieldType.ToString().Equals("\"float\""))
762  {
763  columnType = Column.ColumnType.FLOAT;
764  }
765  else if (fieldType.ToString().Equals("int") || fieldType.ToString().Equals("\"int\""))
766  {
767  columnType = Column.ColumnType.INT;
768  }
769  else if (fieldType.ToString().Equals("long") || fieldType.ToString().Equals("\"long\""))
770  {
771  columnType = Column.ColumnType.LONG;
772  }
773  else if (fieldType.ToString().Equals("string") || fieldType.ToString().Equals("\"string\""))
774  {
775  columnType = Column.ColumnType.STRING;
776  }
777  else
778  {
779  throw new ArgumentException("Field {fieldName} must be of type bytes, double, float, int, long or string.");
780  }
781 
782  IList<string>? columnProperties = null;
783  properties?.TryGetValue(fieldName, out columnProperties);
784  // Check the column properties for nullability
785  if ( ( null != columnProperties ) &&
786  ( columnProperties.Contains( ColumnProperty.NULLABLE ) ) )
787  isColumnNullable = true;
788 
789  // Create the column to be added
790  Column column = new( fieldName, columnType, columnProperties );
791 
792  column.setIsNullable( isColumnNullable );
793 
794  m_data.columns.Add( column );
795 
796  m_data.columnMap[fieldName] = m_data.columns.Count - 1;
797  }
798  } // end CreateSchemaFromString()
799 
803  private void CreateSchema()
804  {
805  // First, check if the schema has already been created
806  if (m_data.schema != null)
807  {
808  // nothing to do
809  return;
810  }
811 
812  // Check if the schema string exists, if so, create the schema from that
813  if (m_data.schemaString != null)
814  {
815  try
816  {
817  m_data.schema = RecordSchema.Parse(m_data.schemaString);
818  return;
819  }
820  catch (Exception ex)
821  {
822  throw new KineticaException(ex.ToString());
823  }
824  } // done creating the schema from the schema string
825 
826  // Since the shortcuts didn't apply, create a JSON object from the columns
827  // and then create the schema and the schema string off it
828  // --------------------------------------------------------------------------
829  // Create the json string for the type
830  string schemaString = "";
831  // Create the json string opening with empty fields (with a generic 'type_name' (because the
832  // server always replaces the name with this string anyway) )
833  string schemaOpening = "{'type':'record','name':'type_name','fields':[";
834  // Create the json string closing
835  string schemaClosing = "]}";
836 
837  schemaString += schemaOpening;
838 
839  // Create the json substrings for the columns
840  foreach (var column in m_data.columns)
841  {
842  // Add the name
843  string fieldName = ("'name':'" + column.getName() + "'");
844 
845  // Add the type
846  string fieldType = "";
847  if (column.isNullable())
848  { // the column is nullable, so we need a union
849  fieldType = ("['" + column.getTypeString() + "','null']");
850  }
851  else // regular type, no union needed
852  {
853  fieldType = ( "'" + column.getTypeString() + "'" );
854  }
855  fieldType = ("'type':" + fieldType);
856 
857  // Put the field together
858  string field = ("{" + fieldName + "," + fieldType + "},");
859  schemaString += field;
860  } // end looping over the fields
861 
862  // Trim the trailing comma from the fields
863  char[] comma = [','];
864  schemaString = schemaString.TrimEnd(comma);
865  // Add the ending of the json string
866  schemaString += schemaClosing;
867 
868  // Create the RecordSchema from the JSON string
869  try
870  {
871  m_data.schema = RecordSchema.Parse(schemaString);
872  }
873  catch (Exception ex)
874  {
875  throw new KineticaException(ex.ToString());
876  }
877 
878  // Save the schema string
879  m_data.schemaString = m_data.schema.ToString();
880  return;
881  } // end CreateSchema()
882  } // end class KineticaType
883 } // end namespace kinetica
const string CHAR1
This property provides optimized memory, disk and query performance for string columns.
ColumnType getType()
Returns the enumeration for the column type.
Definition: KineticaType.cs:55
const string DATETIME
Valid only for 'string' columns.
const string INT16
This property provides optimized memory and query performance for int columns.
const string CHAR128
This property provides optimized memory, disk and query performance for string columns.
bool hasColumn(string name)
KineticaType(string typeSchema)
Create a KineticaType object using the string-formatted schema for the type.
static KineticaType fromObject(Object recordObj, string label="", IDictionary< string, IList< string >> properties=null)
Create a KineticaType object from properties of a record object and Kinetica column properties.
string type_id
An identifier representing the created type.
Definition: CreateType.cs:1006
KineticaType(string label, IList< Column > columns)
Create a KineticaType object with the given column and label information.
int getColumnIndex(string name)
Column properties used for Kinetica types.
Column(string name, ColumnType type, IList< string >? properties=null)
Creates a Column object from the given name, type, and properties.
Definition: KineticaType.cs:35
const string TIMESTAMP
Valid only for 'long' columns.
const string CHAR16
This property provides optimized memory, disk and query performance for string columns.
static KineticaType fromTable(Kinetica kinetica, string tableName)
Create a KineticaType object based on an existing table in the database.
static KineticaType fromTypeID(Kinetica kinetica, string typeId)
Create a KineticaType object based on an existing type in the database.
const string CHAR64
This property provides optimized memory, disk and query performance for string columns.
static KineticaType fromDynamicSchema(string dynamicTableSchemaString, Object[] columnHeaders, Object[] columnTypes)
Create a KineticaType object based on information provided in a dynamic schema.
Column getColumn(int index)
const string CHAR4
This property provides optimized memory, disk and query performance for string columns.
const string CHAR2
This property provides optimized memory, disk and query performance for string columns.
string getTypeString()
Returns the string format of the data type.
Definition: KineticaType.cs:75
const string DATE
Valid only for 'string' columns.
const string CHAR8
This property provides optimized memory, disk and query performance for string columns.
const string DECIMAL
Valid only for 'string' columns.
KineticaType(string label, IList< Column > columns, IDictionary< string, IList< string >> properties)
Create a KineticaType object with the given column, label, and property information.
const string CHAR32
This property provides optimized memory, disk and query performance for string columns.
IList< string > getProperties()
Returns the properties for the column.
Definition: KineticaType.cs:67
IList< Column > getColumns()
const string IPV4
This property provides optimized memory, disk and query performance for string columns representing I...
void saveSourceType(Type sourceType)
Saves the given type as this KineticaType's source type.
const string CHAR256
This property provides optimized memory, disk and query performance for string columns.
static KineticaType fromClass(Type recordClass, IDictionary< string, IList< string >> properties=null)
Create a KineticaType object from properties of a record class and Kinetica column properties.
bool isNullable()
Returns if the column is nullable.
Definition: KineticaType.cs:61
Column getColumn(string name)
static KineticaType fromObject(Object recordObj, IDictionary< string, IList< string >> properties=null)
Create a KineticaType object from properties of a record object and Kinetica column properties.
const string INT8
This property provides optimized memory and query performance for int columns.
string create(Kinetica kinetica)
Given a handle to the server, creates a type in the database based on this data type.
string getName()
Returns the name of the column.
Definition: KineticaType.cs:49
override string ToString()
KineticaType(IList< Column > columns)
Create a KineticaType object with the given column information.
const string TIME
Valid only for 'string' columns.
const string NULLABLE
This property indicates that this column is nullable.
A set of results returned by Kinetica.createType.
Definition: CreateType.cs:1000
API to talk to Kinetica Database
Definition: Kinetica.cs:40
KineticaType(string label, string typeSchema, IDictionary< string, IList< string >> properties, string? typeId=null)
Create a KineticaType object using the string-formatted schema and properties for its columns.
static KineticaType fromClass(Type recordClass, string label, IDictionary< string, IList< string >>? properties=null)
Create a KineticaType object from properties of a record class and Kinetica column properties.