<#576 first draft of auto-detecting schema - [open...
# meltano-repo-activity
g
#576 first draft of auto-detecting schema - [opened] Issue created by MeltyBot Merges infer-schema -> main Migrated from GitLab: https://gitlab.com/meltano/sdk/-/merge_requests/193 --- This is an initial attempt to implement schema inference at stream creation time (See #174 ). Schema inference here is set to run if all other methods for providing a schema fail (i.e., set
scheam = None
in the stream class). The only way to modify the number of records used to infer the schema is to pass it in as a parameter to the creation of the
RESTStream
class (see example in unit tests). There is a placeholder method in the core
Stream
class for schema inference but the major complication to actually running it there is this: The
infer_schema
method needs access to a method like
request_records
which is only implemented in the
RESTStream
class. I have not implemented this in the
GraphQLStream
because a
request_records
method isn't provided there, though we could get the same effect with some extra lines of code. An additional intricacy that needed to be resolved was the timing of the instantiation of
RESTStream
parent class
Stream
. It needed to come after the instantiation of the
self._http_headers
attribute which is required for the
request_records
method to work. This is just a proof of concept and I'm submitting it now in order to get feedback. @aaronsteers , this is a departure from our conversation about this during the call. I decided it would be easier to implement this as part of the SDK directly rather than through a CLI command first so that we could figure out all the dependencies required to run the schema inference appropriately. Later we can implement a CLI command. Unit tests are provided and are the only way I've tested it so far. So if there are more robust methods for testing I would recommend we pursue them. meltano/sdk