Class: DuckDB::Column
- Inherits:
-
Object
- Object
- DuckDB::Column
- Defined in:
- lib/duckdb/column.rb,
ext/duckdb/column.c
Instance Method Summary collapse
-
#logical_type ⇒ DuckDB::LogicalType
Returns the logical type class.
-
#name ⇒ Object
Returns the column name.
-
#type ⇒ Object
returns column type symbol ‘:unknown` means that the column type is unknown/unsupported by ruby-duckdb.
Instance Method Details
#logical_type ⇒ DuckDB::LogicalType
Returns the logical type class.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'ext/duckdb/column.c', line 56
VALUE duckdb_column__logical_type(VALUE oDuckDBColumn) {
rubyDuckDBColumn *ctx;
rubyDuckDBResult *ctxresult;
VALUE result;
duckdb_logical_type _logical_type;
VALUE logical_type = Qnil;
TypedData_Get_Struct(oDuckDBColumn, rubyDuckDBColumn, &column_data_type, ctx);
result = rb_ivar_get(oDuckDBColumn, rb_intern("result"));
ctxresult = get_struct_result(result);
_logical_type = duckdb_column_logical_type(&(ctxresult->result), ctx->col);
if (_logical_type) {
logical_type = rbduckdb_create_logical_type(_logical_type);
}
return logical_type;
}
|
#name ⇒ Object
Returns the column name.
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'ext/duckdb/column.c', line 83
VALUE duckdb_column_get_name(VALUE oDuckDBColumn) {
rubyDuckDBColumn *ctx;
VALUE result;
rubyDuckDBResult *ctxresult;
TypedData_Get_Struct(oDuckDBColumn, rubyDuckDBColumn, &column_data_type, ctx);
result = rb_ivar_get(oDuckDBColumn, rb_intern("result"));
ctxresult = get_struct_result(result);
return rb_utf8_str_new_cstr(duckdb_column_name(&(ctxresult->result), ctx->col));
}
|
#type ⇒ Object
returns column type symbol ‘:unknown` means that the column type is unknown/unsupported by ruby-duckdb. `:invalid` means that the column type is invalid in duckdb.
require 'duckdb'
db = DuckDB::Database.open
con = db.connect
con.query('CREATE TABLE users (id INTEGER, name VARCHAR(30))')
users = con.query('SELECT * FROM users')
columns = users.columns
columns.first.type #=> :integer
17 18 19 20 |
# File 'lib/duckdb/column.rb', line 17 def type type_id = _type DuckDB::Converter::IntToSym.type_to_sym(type_id) end |