SQLProvider icon indicating copy to clipboard operation
SQLProvider copied to clipboard

Question: Support JSON data sources?

Open Thorium opened this issue 7 years ago • 1 comments
trafficstars

Should we made some of the internal classes/interfaces (like 'ISqlProvider') public so that there could be another project, to reference/combine both FSharp.Data and SQLProvider, to allow query { ... }-syntax to be used with queryable data-sources that return JSON. For example:

  • MongoDB
  • Elasticsearch
  • Redis
  • CosmosDB
  • Google Cloud Storage
  • Amazon RDS/Aurora

FSharp.Data can parse JSON sample data. So each provider could use SQLProvider structure and call FSharp.Data to get the schemas, users could then write strongly typed query { ... } and SQLProvider would translate the query to provider specific query-language (if plain SQL is not supported, which often is). The response is basically SqlEntity of column/s that is actually untyped JSON data. FSharp.Data is having JsonValue.Parse that could be used to parse the responses to some more usable format.

Currently these data-sources do have some specific apis/libraries for F#, but don't support the standard query { ... }-syntax. On the other hand I don't know would we get enough users that it would be worth of work.

This is kind of related to Postgres JSON features, #523

Thorium avatar Apr 17 '18 13:04 Thorium

My perspective is biased, because I'm working on a greenfield project, so every JSON in the database is a type I've defined myself first in F# :) Also, almost all of my JSON columns are used to store union types (which are notoriously tricky to represent as ordinary SQL schemas), and how would a type provider deal with those, or more generally with different rows containing different JSON properties? IIRC erasing type providers can't generate DUs.

I imagine this feature would be far more valuable to people doing explorative-type programming (which are actually likely the majority of SqlProvider users?), but I'm not very familiar with those challenges.

piaste avatar Apr 26 '18 17:04 piaste