Athena federated queries against Postgres JSONB field - json

It seems to me that Athena don't understand Postgres JSONB fields, and consider them VARCHARS. This means that any query involving json path expressions will be executed Athena-side, which again means that every row in database must be sent to Athena for evaluation.
How would it be possible to query Postgres JSONB fields with native postgres json functions instead?
Meaning how can I make an Athena query that uses native Postgres functions that are executed on Postgres to filter the rows returned?

Related

Passing JSON list as input in MYSQL Sp

Is there anyway to pass JSON list to mysql stored procedure and insert in that sp?
It has to get the data from the list and insert as separate rows with individual columns.
MySQL has a JSON field type, but it does not understand JSON. MySQL only understands SQL. When you input data into MySQL, it has to be in SQL.
You could use another language to interpret the JSON and convert it to SQL.

Can I use Laravel JSON Where Clauses with MariaDB 10.2.16 LongText column?

I tried to add a json column to my database by using phpMyAdmin
but Unfortunately, phpMyAdmin converts the json column to Longtext type
So, I'm asking about the ability to use the JSON Where Clauses with this type
https://laravel.com/docs/5.7/queries#json-where-clauses
You cannot use those queries on non-JSON data types in MariaDB. And as of 10.2, it doesn't officially support it.
You can use the JSON helper functions to query against data (ie: where JSON_CONTAINS(...) and others.
You can also create columns that are extracted values from the JSON data using Virtual Columns
Here's a good post with much more detail.

How does Javers handle frequent queries against json value fields when MySql doesn't support indexing for json?

I am using Javers with MySql.
Json can be stored in MySql, but is not usually recommended as MySql doesn't support indexing for json.
How does Javers handle frequent queries against json value fields when MySql doesn't support indexing for json?
I would appreciate your answer.
JaVers creates idexes for most fields that you can use in JQL queries - globalId, commitProperties, commitId. For now you cant query by objects' properties so indexing objects snapshots (json) is not required.

how to count json in mysql5.5?

I stored a field of records as JSON "[1,2,3,14,4]"
In MySQL 5.7, I used JSON_LENGTH to count it.
But How can I count in MySQL 5.5.
This is my example query in MySQL 5.7.
SELECT JSON_LENGTH(view_cnt) AS view_cnt FROM `tbl` WHERE `published`=1
Since mysql v5.5 does not have any json support, you need to get creative using string functions.
If your json is simple and does not have values that themselves contain comma, then just count then number of commas within your string and add 1 to it:
select char_length(json_field)-char_length(replace(json_field,',',''))+1 from table
If your json values contain commas, then you would have to write a json parser in mysql to get the length.

How do I convert RDBMS DDL to Hive DDL script

We've a large and disparate data sources including oracle,db2,mysql. We also need to append few audit columns at the end.
I came across the following Java class org.apache.sqoop.hive.HiveTypes. I am planning to create a simple interpreter that accepts RDBMS DDL and spits out Hive DDL script. Any pointers on how I can achieve this?
Hive QL is more or less similar to normal RDBMS DDL. But there are certain things that it lacks and thats why it does not fully follow ANSI SQL. There is no automated process to convert it.
But you have to try running the SQL queries on Hive and wherever it violates you have to change the query according to hive.
For instance Hive takes only equality condition as join condition which is not the case in RDBMS.
For creating an interpreter yourself you first have to list down the common differences between RDBMS query construct and Hive QL construct. Whenever you encounter a RDBMS construct which according to your list will violate in hive the query gets rebuild as per hive. This replacement logic has to be coded.