Comments (1)
For reference, piece of code that I used to find this out:
const duckdb = require('duckdb');
const db = new duckdb.Database(':memory:');
const sql = `
select
1::BIGINT as "_bigint" -- INT8, LONG signed eight-byte integer
, '01'::BIT as "_bit" -- BITSTRING string of 1s and 0s
, 'ab'::BLOB as "_blob" -- BYTEA, BINARY, VARBINARY variable-length binary data
, 1::BOOLEAN as "_boolean" -- BOOL, LOGICAL logical boolean (true/false)
, current_date as "_date" -- DATE calendar date (year, month day)
, 'epoch'::DATE as "_epoch"
, 'infinity'::DATE as "_infinity_date"
, '-infinity'::DATE as "_-infinity_date"
, 3.1415::REAL as "_real" -- FLOAT4, FLOAT single precision floating-point number (4 bytes)
, 3.1415::DECIMAL(5,4) as "_decimal(5,4)"
, 3.1415::DOUBLE as "_double1" -- FLOAT8, double precision floating-point number (8 bytes)
, (0.1 * 0.2)::DECIMAL(19,18) as "_decimal(19,18)"
, (0.1 * 0.2)::DECIMAL(19,18) as "_decimal(19,18)"
, 5.1::DOUBLE * 100 as "_double"
, 5.1::DECIMAL(2,1) * 100 as "_decimal(2,1)"
, 1::HUGEINT as "_hugeint" -- signed sixteen-byte integer
, 2::INTEGER as "_integer" -- INT4, INT, SIGNED signed four-byte integer
, 'Infinity'::DOUBLE as "_infinity"
, '-Infinity'::DOUBLE as "_-infinity"
, 'NaN'::DOUBLE as "_NaN"
, null::double as "_null"
, INTERVAL 1 second as "_interval1s" -- date / time delta
, INTERVAL 1 year as "_interval1y" -- date / time delta
, 42::SMALLINT as "_smallint" -- INT2, SHORT signed two-byte integer
, TIME '1992-09-20 11:30:00.123756' as "_time1" -- time of day (no time zone)
, TIME '1992-09-20 01:30:00.123456' as "_time2" -- time of day (no time zone)
, TIMESTAMPTZ '1992-09-20 11:30:00.123756789' as "_timestamptz" -- TIMESTAMPTZ combination of time and date that uses the current time zone
, TIMESTAMP '1992-09-20 11:30:00.123999999' as "_timestamp" -- DATETIME combination of time and date
, 1::TINYINT as "_tinyint" -- INT1 signed one-byte integer
, 1::UBIGINT as "_ubugint" -- unsigned eight-byte integer
, 1::UHUGEINT as "_uhugeint" -- unsigned sixteen-byte integer
, 1::UINTEGER as "_uinteger" -- unsigned four-byte integer
, 1::USMALLINT as "_usmallint" -- unsigned two-byte integer
, 1::UTINYINT as "_utinyint" -- unsigned one-byte integer
, gen_random_uuid()::UUID as "_uuid" -- UUID data type
, 'bla'::VARCHAR as "_varchar"
, [1, 2, 3] as "_list"
, MAP {'key1': 1, 'key2': 2} as "_map"
, {'x': 1, 'y': 2, 'z': 3} as "_struct"
, 'a'::ENUM('a', 'b') as "_enum"
, [1::BIGINT] as "_[bigint]" -- INT8, LONG signed eight-byte integer
, ['01'::BIT] as "_[bit]" -- BITSTRING string of 1s and 0s
, ['ab'::BLOB] as "_[blob]" -- BYTEA, BINARY, VARBINARY variable-length binary data
, [1::BOOLEAN] as "_[boolean]" -- BOOL, LOGICAL logical boolean (true/false)
, [current_date] as "_[date]" -- DATE calendar date (year, month day)
, [3.1415::REAL] as "_[real]" -- FLOAT4, FLOAT single precision floating-point number (4 bytes)
, [3.1415::DECIMAL(5,4)] as "_[decimal(5,4)]"
, [3.1415::DOUBLE] as "_[double1]" -- FLOAT8, double precision floating-point number (8 bytes)
, [(0.1 * 0.2)::DECIMAL(19,18)] as "_[decimal(19,18)]"
, [5.1::DOUBLE * 100] as "_[double]"
, [5.1::DECIMAL(2,1) * 100] as "_[decimal(2,1)]"
, [1::HUGEINT] as "_[hugeint]" -- signed sixteen-byte integer
, [2::INTEGER] as "_[integer]" -- INT4, INT, SIGNED signed four-byte integer
, [INTERVAL 1 year] as "_[interval1y]" -- date / time delta
, [42::SMALLINT] as "_[smallint]" -- INT2, SHORT signed two-byte integer
, [TIME '1992-09-20 01:30:00.123756'] as "_[time1]" -- time of day (no time zone)
, [TIME '1992-09-20 11:30:00.123456'] as "_[time2]" -- time of day (no time zone)
, [TIMESTAMPTZ '1992-09-20 11:30:00.123456789'] as "_[timestamptz]" -- TIMESTAMPTZ combination of time and date that uses the current time zone
, [TIMESTAMP '1992-09-20 11:30:00.123456789'] as "_[timestamp]" -- DATETIME combination of time and date
, [1::TINYINT] as "_[tinyint]" -- INT1 signed one-byte integer
, [1::UBIGINT] as "_[ubugint]" -- unsigned eight-byte integer
, [1::UHUGEINT] as "_[uhugeint]" -- unsigned sixteen-byte integer
, [1::UINTEGER] as "_[uinteger]" -- unsigned four-byte integer
, [1::USMALLINT] as "_[usmallint]" -- unsigned two-byte integer
, [1::UTINYINT] as "_[utinyint]" -- unsigned one-byte integer
, [gen_random_uuid()::UUID] as "_[uuid]" -- UUID data type
, ['bla'::VARCHAR] as "_[varchar]"
`;
db.all(sql, function(err, res) {
if (err) {
console.warn(err);
return;
}
const row = res[0];
const keys = Object.keys(row);
for (let i = 0; i < keys.length; i++){
const key = keys[i];
const value = row[key];
let type = typeof value;
if (key.startsWith('_interval')) {
type += ' ' + JSON.stringify(Object.keys(value).reduce(function(acc, curr){
acc[curr] = typeof value[curr];
return acc ;
}, {}));
}
const ctor = value ? value.constructor : undefined;
console.log('column: ', key, '; type: ', type, '; value: ', value, '; constructor: ', String(ctor));
if (value instanceof Date) {
console.log(value.getMilliseconds());
}
}
//console.log(obj);
});
from duckdb-web.
Related Issues (20)
- Docs for `quantile_cont` do not describe how interpolation is calculated
- Issue found on page 'Aggregate Functions': quantile_cont(x, pos) aggregate function takes value in the range [-1, 1] for pos, needs documentation
- Issue found on page 'Querying Parquet Metadata' HOT 1
- [duckdb/#13191] - Add catalog_error_max_schemas setting that toggles how many schemas we look at for "did you mean..." style error messages needs documentation
- Minima warning
- Issue found on page 'Samples' HOT 1
- Improve spatial extension docs by linking the extension's own docs
- [duckdb/#13162] - [CSV Reader] Comment Option needs documentation
- Issue found on page 'CSV Import': "auto_type_candidates Details" section could benefit from a cross link to https://duckdb.org/docs/data/csv/auto_detection#type-detection
- Issue found on page 'Data Types': REAL is listed as datatype but it would be more appropriate to use FLOAT instead
- Issue found on page 'CSV Import': auto_type_candidate Details section should list all allowed data types and point out data types that aren't listed are not supported.
- Feature Request: Dark mode for the docs HOT 1
- Re-enable "update docs" CI job
- Mention that tables can be selected as a STRUCT when using the table name in the select clause HOT 2
- [duckdb/#12886] - NO_PARTITION_COLUMNS option to skip partition writes for Parquet copy needs documentation
- Issue found on page 'C API'
- Issue found on page 'C API' HOT 5
- Issue found on page 'Appender' HOT 1
- WebAssembly (Wasm) limitations
- Issue found on page 'CSV Auto Detection' - sniff_csv-function arguments
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from duckdb-web.