Comments (4)
These are good points and they should be added to the docs. In general I think some of the confusion comes from using the different terminology for the same concepts, which should probably be cleaned up.
Here are some answers to your questions:
What is the difference (if any) between ARRAY, INT[], and LIST?
These are all different names for the same terminology. INT[]
is an integer array, and LIST
is what we call this internally.
Can the exact size of an array be used in a DDL statement (INT[3])? Are these limits respected?
Yes and no. The limits are ignored right now. You could simulate the enforcement through a CHECK
constraint, though:
D create table integers(i int[3] check(len(i)<=3));
D insert into integers values ([1, 2, 3, 4, 5]);
Error: Constraint Error: Constraint Error: CHECK constraint failed: integers
D insert into integers values ([1, 2]);
How is the type of a LIST or ARRAY specified in a DDL statement?
LIST
and ARRAY
cannot be used in DDL statements. ARRAY
can only be used for values (e.g. select array[1,2,3];
), same for the list_value
function (e.g. select list_value(1, 2, 3)
). In DDL statements you need to use the type, e.g. INT[]
.
Can LIST expressions ([1, 2, 3]) be used to insert into ARRAYs?
Yes, they are the same. See above.
What is the difference (if any) between STRUCT, ROW, and MAP?
STRUCT
and ROW
are the same internally, but are different in that ROW
constructors do not have explicit names, e.g.:
SELECT row(1, 'hello');
SELECT {'i': 1, 'j': 'hello'};
They can mostly be used interchangeably. Row elements will be given names v1
, v2
, etc.
MAP
is different because every row can have different keys, e.g.:
select map(['key1', 'key2'], [1, 2]) union all select map(['key1'], [1]);
┌───────────────────────────────────────────────┐
│ map(list_value(key1, key2), list_value(1, 2)) │
├───────────────────────────────────────────────┤
│ {key1=1, key2=2} │
│ {key1=1} │
└───────────────────────────────────────────────┘
Can STRUCT expressions ({'foo': ...}) be used to insert into MAPs or ROWs?
Rows are the same as structs, so yes. For maps this is not possible (yet) but should probably be possible, at least for maps with varchar keys.
from duckdb-web.
Thanks for the extensive answer! I figured most of this out by playing around in the CLI, but now this ^^ can be added to the docs.
from duckdb-web.
I think we can close this now!
from duckdb-web.
Yep!
from duckdb-web.
Related Issues (20)
- [duckdb/#12141] - Some duckdb types in `duckdb.h` are not documented needs documentation
- [duckdb/#12123] - Move excel extension out of tree needs documentation HOT 1
- Reduce use of visible spaces
- [duckdb/#12240] - Fix #12225: revert OVERWRITE_OR_IGNORE to previous behavior, move new behavior to OVERWRITE flag needs documentation
- [duckdb/#12105] - Slow performance of duckdb_stream_fetch_chunk needs documentation
- [duckdb/#12262] - Add support for APPEND argument to hive partitioned write needs documentation
- Issue found on page Excel Export HOT 1
- bundle interfaces under a new category 'data sources'
- [duckdb/#12300] - Remove sqlsmith extension needs documentation
- [duckdb/#12286] - Why is the db.file size still large after deleting data or dropping tables? needs documentation HOT 2
- [duckdb/#12220] - Add `RETURN_FILES` parameter to `COPY TO` needs documentation
- Dockerfile is broken
- [duckdb/#12299] - Aggregate Regression function SLOPE and INTERCEPT seem to produce wrong results needs documentation
- [duckdb/#12337] - Make `dbgen` generate data in parallel needs documentation HOT 1
- Issue found on page 'Node.js API': .all method on Database / Connection can execute multiple statements but documentation suggests this is not possible
- Issue found on page 'Attach to a DuckDB Database over HTTPS or S3' HOT 1
- Node JS API docs: would be nice to have a page that describes the mapping of the DuckDB data types to the JavaScript type system HOT 1
- Document C-API deprecations
- [duckdb/#12350] - cli: Stuck at the intialization needs documentation HOT 1
- [duckdb/#12317] - Combining LIST_CONCAT and CONCAT binding needs documentation HOT 1
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.