Skip to content

Instantly share code, notes, and snippets.

@rg443a
Created June 7, 2024 20:30
Show Gist options
  • Save rg443a/6ae8b251b16c0d1c1f17339ad2bb20b2 to your computer and use it in GitHub Desktop.
Save rg443a/6ae8b251b16c0d1c1f17339ad2bb20b2 to your computer and use it in GitHub Desktop.
duckdb inet_aton function
CREATE OR REPLACE FUNCTION inet_aton(ip) AS (
cast(
split_part(ip, '.', 1)::UINTEGER * 16777216 +
split_part(ip, '.', 2)::UTINYINT * 65536 +
split_part(ip, '.', 3)::UTINYINT * 256 +
split_part(ip, '.', 4)::UTINYINT as UINTEGER)
);
-- select inet_aton('255.255.255.252');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment