0

I am trying to pull hostname and path from urls without scheme but parse_url doesn't works. What all other options do I have?

  • Can you please provide examples? PARSE_URL gives you separate "host" and "path" already, you can just ignore the "scheme", unless I miss something? – Eric Lin Mar 23 '22 at 10:46

1 Answers1

0

PARSE_URL does not work without scheme -

SNOWFLAKE1#COMPUTE_WH@TEST_DB.PUBLIC>SELECT PARSE_URL('www.snowflake.com');
100139 (22000): Error parsing URL: scheme not specified
SNOWFLAKE1#COMPUTE_WH@TEST_DB.PUBLIC>SELECT PARSE_URL('http://www.snowflake.com');
+---------------------------------------+
| PARSE_URL('HTTP://WWW.SNOWFLAKE.COM') |
|---------------------------------------|
| {                                     |
|   "fragment": null,                   |
|   "host": "www.snowflake.com",        |
|   "parameters": null,                 |
|   "path": null,                       |
|   "port": null,                       |
|   "query": null,                      |
|   "scheme": "http"                    |
| }                                     |
+---------------------------------------+
1 Row(s) produced. Time Elapsed: 0.229s

Wondering if you are looking for something like below -

Split a column into multiple columns by delimiter and recombine from last column to first using SQL

SNOWFLAKE1#COMPUTE_WH@TEST_DB.PUBLIC>select value from table(split_to_table('com.dqm.abcv.xyz.google', '.'));
+--------+
| VALUE  |
|--------|
| com    |
| dqm    |
| abcv   |
| xyz    |
| google |
+--------+
5 Row(s) produced. Time Elapsed: 0.566s
Pankaj
  • 2,692
  • 2
  • 6
  • 18