⌘K ctrl+k
Search Shortcut cmd + k | ctrl + k
DuckDB 2.0 ドキュメント 全文検索
per page, with , order by , clip by
Results of 1 - 10 of about 23 for Casting (0.002 sec.)
Typecasting 14260
Typecasting is an operation that converts a value in one particular data type to the closest corresponding value in another data type. Like other SQL engines, DuckDB supports both implicit and explicit typecasting. Explicit Casting Explicit ... typecasting is performed by using a CAST expression. For example, CAST(col AS VARCHAR) or col::VARCHAR explicitly cast the column col ... to VARCHAR . See the cast page for more information. Implicit Casting In many situations, the system will add casts by itself. This is called implicit casting and happens, for example, when a ... on. Tip To check whether a type can be implicitly cast to another type, use the can_cast_implicitly function . Combination Casting When values of different types need to be combined to an unspecified joint parent type, the system will perform implicit c ...
https://man.mtool.work/duckdb/2.0/sql/data_types/typecasting.html
Casting 12165
Casting refers to the operation of converting a value in a particular data type to the corresponding value in another data type. Casting can occur either implicitly or explicitly. The syntax described here performs an explicit cast. More in ... formation on casting can be found on the typecasting page . Explicit Casting The standard SQL syntax for explicit casting is CAST(expr AS TYPEN ... AR) AS i FROM generate_series(1, 3) tbl(i); i 1 2 3 SELECT i::DOUBLE AS i FROM generate_series(1, 3) tbl(i); i 1.0 2.0 3.0 Casting Rules Not all casts are possible. For example, it is not possible to convert an INTEGER to a DATE . Casts may also throw e ... vert string 'hello' to INT32 The exact behavior of the cast depends on the source and destination types. For example, when casting from VARCHAR to any other type, the string will be attempted to be converted. Casting between numeric types might have rou ...
https://man.mtool.work/duckdb/2.0/sql/expressions/cast.html
Union Type 10540
A UNION type (not to be confused with the SQL UNION operator ) is a nested type capable of holding one of multiple “alternative” values, much like the union in C. The main difference is that these UNION types are tagged unions and thus alwa ... and simply keep the “tag” as the first entry. UNION values can be created with the union_value(tag := expr) function or by casting from a member type . Example Create a table with a UNION column: CREATE TABLE tbl1 (u UNION(num INTEGER, str VARCHAR)); IN ... embers are a subset of the target's (if the cast is unambiguous). UNION uses the member types' VARCHAR cast functions when casting to VARCHAR : SELECT u FROM tbl1; u 1 two three Select all the str members: SELECT union_extract(u, 'str') AS str FROM tbl1 ... into one of its members, you should use the union_extract function explicitly instead. The only exception to this is when casting a UNION to VARCHAR , in which case the members will all use their corresponding VARCHAR casts. Since everything can be cas ...
https://man.mtool.work/duckdb/2.0/sql/data_types/union.html
TRY Expression 8696
The TRY expression ensures that errors caused by the input rows in the child (scalar) expression result in NULL for those rows, instead of causing the query to throw an error. The TRY expression was inspired by the TRY_CAST expression . Exa ... lls return errors when invoked without the TRY expression. When they are wrapped into a TRY expression, they return NULL : Casting Without TRY SELECT 'abc'::INTEGER; Conversion Error: Could not convert string 'abc' to INT32 With TRY SELECT TRY('abc'::IN ... ession, or SET error_on_division_by_zero=false to return NULL for all divisions by zero. With TRY SELECT TRY(1 // 0); NULL Casting Multiple Rows Without TRY WITH cte AS (FROM (VALUES ('123'), ('test'), ('235')) t(a)) SELECT a::INTEGER AS x FROM cte; Con ...
https://man.mtool.work/duckdb/2.0/sql/expressions/try.html
Struct Data Type 8629
Conceptually, a STRUCT column contains an ordered list of columns called “entries”. The entries are referenced by name using strings. This document refers to those entry names as keys. Each row in the STRUCT column must have the same keys. ... ats without a tuple type, such as Parquet, tuples are stored as structs with the generated keys element1 , element2 , etc. Casting between Tuples and Structs Tuples can be cast to structs with the same number of entries, and vice versa. The entries are ... ollowing produces the same result as above: CREATE TABLE t1 AS ( SELECT row('a', 42)::STRUCT(v VARCHAR, i INTEGER) AS s ); Casting between a tuple and a struct with a different number of entries fails. Casting between Structs When casting between struct ... ferent types are implicitly cast to a struct type with the union of the involved keys, following the rules for combination casting . The following queries return true : SELECT {'k1': 0, 'k2': 0} < {'k1': 1, 'k2': 0}; SELECT {'k1': 'hello'} < {'k1': 'wor ...
https://man.mtool.work/duckdb/2.0/sql/data_types/struct.html
Comparisons 8361
Comparison Operators The table below shows the standard comparison operators. Whenever either of the input arguments is NULL , the output of the comparison is NULL . Operator Description Example Result < less than 2 < 3 true > greater than ... LL 2 IS DISTINCT FROM NULL true IS NOT DISTINCT FROM equal, including NULL NULL IS NOT DISTINCT FROM NULL true Combination Casting When performing comparison on different types, DuckDB performs Combination Casting . These casts were introduced to make i ...
https://man.mtool.work/duckdb/2.0/sql/expressions/comparison_operators.html
Pragmas 8160
The PRAGMA statement is a SQL extension adopted by DuckDB from SQLite. PRAGMA statements can be issued in a similar manner to regular SQL statements. PRAGMA commands may alter the internal state of the database engine, and can influence the ... ct. To allow this behavior, use the order_by_non_integer_literal option: SET order_by_non_integer_literal = true; Implicit Casting to VARCHAR Prior to version 0.10.0, DuckDB would automatically allow any type to be implicitly cast to VARCHAR during func ... st. For version v0.10.0 and later an explicit cast is needed instead. To revert to the old behavior that performs implicit casting, set the old_implicit_casting variable to true . Note that this setting is deprecated and will be removed in a future rele ... ase: SET old_implicit_casting = true; Python: Scan All Dataframes Prior to version 1.1.0, DuckDB's replacement scan mechanism in Python scanned the glob ...
https://man.mtool.work/duckdb/2.0/configuration/pragmas.html
Reading Faulty CSV Files 8093
CSV files can come in all shapes and forms, with some presenting many errors that make the process of cleanly reading them inherently difficult. To help users read these files, DuckDB supports detailed error messages, the ability to skip fa ... the following table: CREATE TABLE people (name VARCHAR, birth_date DATE); DuckDB detects the following error types: CAST : Casting errors occur when a column in the CSV file cannot be cast to the expected schema value. For example, the line Pedro,The 90 ... the file would fail, as the string three cannot be converted to an INTEGER . For example, the following query will throw a casting error. FROM read_csv('faulty.csv', columns = {'name': 'VARCHAR', 'age': 'INTEGER'}); However, with ignore_errors set, the ... ction pushdown optimization. Hence, if we were to select only the name column, both rows would be considered valid, as the casting error on the age would never occur. For example: SELECT name FROM read_csv('faulty.csv', columns = {'name': 'VARCHAR', 'ag ...
https://man.mtool.work/duckdb/2.0/data/csv/reading_faulty_csv_files.html
Numeric Types 8093
Fixed-Width Integer Types The types TINYINT , SMALLINT , INTEGER , BIGINT and HUGEINT store whole numbers, that is, numbers without fractional components, of various ranges. Attempts to store values outside of the allowed range will result ... the uuid_extract_timestamp function : SELECT uuid_extract_timestamp(uuidv7()) AS ts; ts 2025-04-19 15:51:20.07+00 Rounding Casting from floating-point or fixed-point types to integers means that the source numbers are rounded. The following default roun ... ding logic applies: Casting from FLOAT and DOUBLE to integers of any size: round to the nearest integer, with ties (halfs) rounded to the nearest even ... ql SELECT 2.5::FLOAT::INTEGER AS result; -- round to even text ┌────────┐ │ result │ │ int32 │ ├────────┤ │ 2 │ └────────┘ Casting from DECIMAL to integers of any size: round to the nearest integer, with ties (halfs) rounded away from zero. sql SELECT 2 ...
https://man.mtool.work/duckdb/2.0/sql/data_types/numeric.html
Bitstring Type 7959
Name Aliases Description BITSTRING BIT Variable-length strings of 1s and 0s Bitstrings are strings of 1s and 0s. The bit type data is of variable length. A bitstring value requires 1 byte for each group of 8 bits, plus a fixed amount to sto ... ing('0101011', 12) AS b; b 000000101011 Numeric values (integer and float values) can also be converted to a BITSTRING via casting. For example: SELECT 123::BITSTRING AS b; b 00000000000000000000000001111011 Functions See Bitstring Functions . ...
https://man.mtool.work/duckdb/2.0/sql/data_types/bitstring.html
PREV 1 2 3 NEXT
DuckDB 2.0 Documentation / man.mtool.work