Skip to content
Advertisement

Tag: presto

Search for exact string value in JSON

I have a column stored in JSON that looks like column name: s2s_payload Values: I want to query exact values in the array rather than returning all values for a certain data type. I was using JSON_EXTRACT to get distinct counts. If I want to filter where “”eventtype””:””search”” how can I do this? I tried using CAST(s2s_payload AS CHAR) =

Creating bins in presto sql – programmatically

I am new to Presto SQL syntax and and wondering if a function exists that will bin rows into n bins in a certain range. For example, I have a a table with 1m different integers that range from 1 – 100. What can I do to create 20 bins between 1 and 100 (a bin for 1-5, 6-10, 11-15

how to find Age from DOB in Athena?

Here is my query to find out age from the DOB column : I am getting following error: SYNTAX_ERROR: line 4:47: ‘-‘ cannot be applied to varchar, varchar Appreciate your help! Answer You should be able to solve this using function DATE_DIFF(). From the documentation: date_diff(unit, timestamp1, timestamp2) → bigint Returns timestamp2 – timestamp1 expressed in terms of unit. Try:

Presto – hex string to int

I’m trying to convert hex string (starts with ‘0x’) to it’s integer value using presto. For example 0x100 to 256. My hex string is called msg_id. I tried to use this- But I run into a problem, because from_hex expect even number of hex digits (0100 instead of 100). I decided to try and solve this using an if statement,

Presto create table with ‘with’ queries

typically to create a table in Presto (from existing db tables), I do: But to make my code simple, I’ve broken out subqueries like this: Where do I put the create table statement here? The actual query is more complex than the above so I am trying to avoid having to put the subqueries within the main query. Answer This

Advertisement