Fix “list dimensions must be equal” in DuckDB

If you’re getting an error in DuckDB that includes “list dimensions must be equal“, it appears that you’re performing a list operation that requires the lists to be the same dimension, but the lists are of different dimensions.

To fix this error, be sure to use lists of equal dimensions when performing the operation.

Read more

Add Minutes to a Date/Time Value in DuckDB

Date/time arithmetic, such as adding one or more minutes to a date/time value, is an operation we often need to perform when using SQL databases such as DuckDB. As with most RDBMSs, DuckDB makes this easy for us to achieve.

Here are two options for adding one or more minutes to a date, timestamp, or time value.

Read more

An Overview of DuckDB’s TYPEOF() Function

DuckDB offers a variety of utility functions to help us better understand the data that we need to work with. Among these functions, typeof() serves as a useful tool for type inspection and validation. In this article, we’ll explore how this function works, along with examples that demonstrate its usage.

Read more

Using TRY_CAST() to Handle Errors When Converting Between Data Types in DuckDB

Encountering errors while converting between data types can be frustrating when working with SQL databases like DuckDB. But it usually means that something’s wrong. In most cases these errors occur because we’re trying to perform an impossible conversion, like from a number to a date or something.

But sometimes errors can get in the way, especially when we’re trying to convert a bunch of values. Sometimes it would be better for the system to return NULL for such failed conversions than to return an error and mess up the whole operation. Fortunately, we can do this.

Read more

A Quick Look at the LIST_AGGREGATE() Function in DuckDB

DuckDB’s list_aggregate() function is a handy tool for performing grouped aggregations over lists. It allows us to apply any aggregate function (like sum, avg, min, max, count, etc.) to a list column as if each list item were a row.

The way it works is that we pass the list as the first argument, followed by the name of an aggregate function we want to apply to that list. The function will return its result as if it were the named aggregate function.

Read more

Fix “No function matches the given name and argument types ‘list_concat…” When Using array_push_front() or array_push_back() in DuckDB

If you’re getting a binder error that reads something like “No function matches the given name and argument types ‘list_concat(STRING_LITERAL, VARCHAR[][])’. You might need to add explicit type casts.” in DuckDB when using either the array_push_front() or array_push_back() functions, it could be due to a slight syntax error.

Read more