In DuckDB, ISFINITE()
is a function for checking whether values are finite. DuckDB supports infinite values, and so we can use this function to check whether a value is infinite or not. This can be useful when working with floating-point data that might contain special values like NaN (Not a Number) or infinity. We can also use it on date and timestamp values.
Tag: what is
How ARG_MAX_NULL() Works in DuckDB
In DuckDB, the arg_max_null()
function works in a similar way to the arg_max()
function, in that it finds the row with the maximum value in one column and returns the corresponding value from another column at that row.
But where it differs from arg_max()
is in the way it deals with NULL values. Also, arg_max_null()
only accepts two arguments, whereas arg_max()
accepts an optional third argument. Additionally, there aren’t any aliases for arg_max_null()
at the time of writing (arg_max()
has a couple of aliases).
In this article we’ll look at how arg_max_null()
works, and we’ll compare it with arg_max()
to see how each function handles NULL values.
A Quick Overview of DuckDB’s LAST() Function
DuckDB is an in-process SQL OLAP database management system designed for analytical workloads. Among its many functions is one called last()
. This function returns the last value in a column.
Let’s take a look at the last()
function in DuckDB.
The Difference Between AGE() and DATE_DIFF() in DuckDB
Both AGE()
and DATE_DIFF()
are DuckDB functions used to calculate time differences, but they serve distinct purposes and exhibit different behaviors that are important to understand when working with temporal data.
This article explores the difference between these two functions.
Continue readingUsing MAKE_DATE() to Construct a Date in DuckDB
In DuckDB, the make_date()
function enables us to create date values from individual year, month, and day components. This function is particularly useful when working with data that stores date components separately or when constructing date values programmatically.
MAX_BY() Examples in DuckDB
DuckDB has a max_by()
function that finds the row with the maximum value in one column and returns the corresponding value from another column at that row.
Below are some examples that demonstrate how it works.
Continue readingExploring the FIRST() Function in DuckDB
One of the aggregate functions available in DuckDB is the FIRST()
function, which returns the first value from each group in a query.
Let’s take a look at some examples of using the FIRST()
function in DuckDB
Using the .nullvalue Command to See NULL Output in the DuckDB CLI
By default, when a query returns a null value in the DuckDB command line interface (CLI), an empty string is displayed. This may or may not be what you want. But if you’re like me, you probably want DuckDB to explicitly tell you that it’s a null value. After all, if an empty string is returned, perhaps the data contained an empty string?
Fortunately, DuckDB provides us with the .nullvalue
dot command so that we can change the output of null values.
Formatting Dates with STRFTIME() in DuckDB
In DuckDB, the strftime()
function is a handy tool for formatting date and timestamp values as strings. It accepts the date/timestamp value and a format string as arguments. The function then returns the date/time in the format provided by the format string.
Understanding the STRPTIME() Function in DuckDB
DuckDB provides us with a good selection of date/time functions. The strptime()
function is a useful one for times where you need to convert a date string into a valid timestamp value; its sole purpose is to parse strings into timestamps.
In this article, we’ll look at how the strptime()
function works, along with some examples to demonstrate.