If you’re getting an error that reads something like “Sample method System cannot be used with a discrete sample count” when using the SAMPLE
clause in DuckDB, it looks like you’re specifying an invalid sampling method for the context with which you’re using the SAMPLE
clause. Perhaps you’re using system or bernoulli, when you should be using reservoir.
Understanding the GREATEST() Function in DuckDB
The GREATEST()
function in DuckDB is a versatile utility that returns the greatest value from a list of expressions. The function works across various data types and provides flexible comparison capabilities for data analysis tasks.
This article takes a look at DuckDB’s GREATEST()
function, along with some simple examples.
Check if a Sub-List Appears in a Larger List in DuckDB: LIST_HAS_ALL()
When working with lists in DuckDB, we sometimes need to check whether a list contains specific elements. The list_has_all()
function is a handy tool that allows us to verify if all elements of one list exist within another. This function is particularly useful in filtering queries, data validation, and advanced list-based operations.
In this article, we’ll explore how list_has_all()
works in DuckDB.
Fix ‘Binder Error: Could not find key “…” in struct’ When Using DuckDB’s ARRAY_EXTRACT() Function
If you’re getting an error that reads something like “Binder Error: Could not find key “…” in struct” when using the array_extract()
function in DuckDB, it could be that you’re specifying a non-existent key.
When using DuckDB’s array_extract()
function to extract a value from a struct, we must provide a key that actually exists in the struct. Otherwise we’ll end up with an error like the above one.
To fix this issue, be sure to specify a key that actually exists in the struct.
Continue readingFlattening Nested Lists with DuckDB’s FLATTEN() Function
DuckDB has a flatten()
function that we can use to flatten nested lists. The function concatenates a list of lists into a single list. So whether the outer list contains just one list or multiple lists, we can use the flatten()
function to flatten them into one list.
However, it only goes one level deep, so that’s something to keep in mind.
Continue reading5 Functions that Concatenate Lists in DuckDB
DuckDB provides us with a bunch of list concatenation functions that do exactly the same thing; concatenate two lists. Actually, they’re all synonyms and so they can all be used interchangeably. There’s also a more general concatenation function that can also be used on lists.
So this article presents five functions that we can use to concatenate lists.
Continue readingHow to Get the Abbreviated Day Name in DuckDB
When working with DuckDB, sometimes we might need to get the weekday name from a date or timestamp value. And sometimes we might want just the abbreviated weekday name, rather than the full name. For example, we might want Mon instead of Monday.
Continue readingFix “Could not convert string ‘…’ to INT64” When Using the GENERATE_SUBSCRIPTS() Function in DuckDB
If you’re getting an error that reads something like “Could not convert string ‘…’ to INT64” when using the generate_subscripts()
function in DuckDB, it appears that your second argument is a string, when it should be an integer.
DuckDB’s generate_subscripts()
function accepts two arguments; the array as the first argument, and the dimension as the second argument. The second argument must be INT64
(or be able to be implicitly converted to that type). Passing the wrong data type as the second argument can cause the above error to occur.
To fix this issue, make sure that the second argument is compatible with INT64
.
Taking a Look at the LEAST() Function in DuckDB
In DuckDB, the LEAST()
function returns the smallest value from a list of expressions. The function works across various data types and provides flexible comparison capabilities for data analysis tasks.
In this article, we’ll explore DuckDB’s LEAST()
function with some simple examples.
Understanding EXTRACT() in DuckDB
DuckDB offers a variety of date functions, one of which is the extract()
function. This function is designed to retrieve a specific date part from a date or timestamp value, and it can also be applied to intervals.
In this article, we’ll take a closer look at the extract()
function and provide some straightforward examples to illustrate how it works.