MeridianMERIDIAN

Query String Parameters

container.key_value.query_string

URL query string format: key1=value1&key2=value2. Commonly found in URLs and HTTP POST bodies.

Try a value

Query String Parameters's rule accepts it.

Reads it as name=John&age=30&city=NewYork

Use it

Shell
finetype infer -i 'name=John&age=30&city=NewYork' --mode column
# → container.key_value.query_string
DuckDB
SELECT ft_infer('name=John&age=30&city=NewYork');
-- → 'container.key_value.query_string'
Cast template: {col} is your column
CAST({col} AS VARCHAR)
Casts to
VARCHAR

Pattern

Regular expression
^(?:[^=&]+=[^&]*(?:&[^=&]+=[^&]*)*|(?:[^=&\s]+&|&)*[^=&\s]+=(?:[^=&][^&]*)?(?:&(?:[^=&\s]+(?:=(?:[^=&][^&]*)?)?)?)*)$
ValueLengthShape
name=John&age=30&city=NewYork29matches
q=python&page=115matches
user_id=123&token=abc123xyz27matches

Background

Origin

RFC 3986, Uniform Resource Identifier (URI): Generic Syntax, was published in January 2005 by T. Berners-Lee, R. Fielding and L. Masinter.[1] RFC 3986 defines the query component of a URI as the part indicated by the first question mark and terminated by a number sign or by the end of the URI.[1]

The WHATWG URL Standard now defines the application/x-www-form-urlencoded format as a way to encode a list of tuples, each consisting of a name and a value.[2] The URL Standard calls the format in many ways an aberrant monstrosity, the result of many years of implementation accidents and compromises, and says it is in widespread use due to the prevalence of HTML forms.[2]

Use

A column of query strings in a data file is best read as a small record of named fields per row, flattened into one string. (Meridian's view) Splitting on & and = by hand is tempting but fragile, so reach for a real form-urlencoded parser and keep the raw string alongside the parsed fields. (Meridian's view)

The URL Standard's parser replaces any + in names and values with a space before percent-decoding them as UTF-8.[2] The URL Standard says only UTF-8 is conforming, though a legacy server-oriented implementation might have to support other encodings.[2]

Python's parse_qs ignores blank values by default unless keep_blank_values is set to a true value.[3]

RFC 1866 notes that because & also begins an SGML entity reference, a URI such as http://host/?x=1&y=2 must be written with & or & inside an HTML attribute.[4]

How it's detected

URL query string format. Values are typically URL-encoded. Recursive inference parses key-value pairs and types each value independently. The WHATWG URL Standard allows bare names and empty sequences beside pairs; at least one name=value pair is required here, so a column of bare names is not a query string. A sequence of only name=value pairs keeps the looser reading (any name text); once a bare name or an empty sequence appears, names may not hold whitespace and a value may not start with `=`, so expression text such as `a == 1 && b == 2` is not a query string.

Schema

https://meridian.online/schemas/container.key_value.query_string · Frictionless type string

finetype taxonomy container.key_value.query_string -o json-schema

Type Registry