URL Functions in Presto/Athena
Dendi Handian

Dendi Handian @dendihandian

About: Data Engineer - Building Data Lake & Modern Data Architecture

Location:
Jakarta
Joined:
Oct 13, 2019

URL Functions in Presto/Athena

Publish Date: Mar 18
0 2

Extract Host

SELECT url_extract_host('https://example-subdomain.example-host.com/path/to/detail?order=desc&page=10')

-- example-subdomain.example-host.com
Enter fullscreen mode Exit fullscreen mode

Extract Parameter

SELECT url_extract_parameter('https://example-subdomain.example-host.com/path/to/detail?order=desc&page=10', 'page')

-- 10
Enter fullscreen mode Exit fullscreen mode

Extract Path

SELECT url_extract_path('https://example-subdomain.example-host.com/path/to/detail?order=desc&page=10')

-- /path/to/detail
Enter fullscreen mode Exit fullscreen mode

Extract Port

SELECT url_extract_port('https://example-subdomain.example-host.com:8088/path/to/detail?order=desc&page=10')

-- 8088
Enter fullscreen mode Exit fullscreen mode

Extract Protocol

SELECT url_extract_protocol('https://example-subdomain.example-host.com:8088/path/to/detail?order=desc&page=10')

-- https
Enter fullscreen mode Exit fullscreen mode

Extract Query

SELECT url_extract_query('https://example-subdomain.example-host.com:8088/path/to/detail?order=desc&page=10')

-- order=desc&page=10
Enter fullscreen mode Exit fullscreen mode

Extract Fragment

SELECT url_extract_fragment('https://example-subdomain.example-host.com:8088/path/to/detail?order=desc&page=10#header1')

-- header1
Enter fullscreen mode Exit fullscreen mode

Comments 2 total

  • xavyfow
    xavyfowMar 19, 2025

    When this will be useful and where we can use this codes @dendihandian

    • Dendi Handian
      Dendi HandianMar 20, 2025

      If you have AWS account, you can try it on Athena. I'm still looking for presto sql playground to be tried for these queries...

Add comment