DYNAMIC SCHEMA TYPING
In one example in accordance with the present disclosure, a method for dynamic schema typing may include receiving a host query with a function defining data to be retrieved. The function may include a dynamically definable schema. The method may also include receiving, at function invocation time, a data type schema defining a type of the data to be retrieved and generating a query using the data type schema as a value for the dynamically definable schema. The method may also include retrieving the data, converting the retrieved data into a form defined by the data type schema and providing the transformed data to the host query.
1 . A method for dynamic schema typing, the method comprising:
receiving a host query with a function defining data to be retrieved, wherein the function includes a dynamically definable schema;
receiving, at a function invocation time, a data type schema defining a type of the data to be retrieved;
generating a query using the data type schema as a value for the dynamically definable schema;
retrieving the data;
converting the retrieved data into a form defined by the data type schema; and
providing the transformed data to the host query.
2 . The method of claim 1 , wherein the dynamically definable schema is initially set to a null value.
3 . The method of claim 1 , further comprising:
performing an SQL query including the function and the data type schema.
4 . The method of claim 1 , further comprising:
receiving a second data type schema defining a second type of the data to be retrieved, wherein the data type schema and the second data type schema are different; and
generating a second query using the second data type schema as a value for the dynamically definable schema.
5 . The method of claim 1 , further comprising:
retrieving the data from an unstructured data source.
6 . The method of claim 1 , wherein the function is created by a User Defined Transformation Factory.
7 . The method of claim 1 , wherein the data type schema further defines a first node in a cluster, the method further comprising;
receiving, at the function invocation time, a second data type schema, wherein the second data type schema defines a second type of data to be retrieved from a second node in the cluster; and
retrieving, in parallel, the first type of data from the first node in the cluster and second type of data from the second node in the cluster.
8 . A system for dynamic schema typing, the method comprising:
a function receiver to receive a function with a schema variable, wherein the function is created by a function factory;
a value receiver to receive, at run time, a type value for the schema variable, wherein the type value defines a type of data;
a query generator to dynamically generate an SQL query using the type value as the schema variable for the function; and
a function performer to perform the function using the type value.
9 . The system of claim 8 , wherein the function factory is registered before the function is invoked.
10 . The system of claim 8 , wherein the type value further defines a property of the data.
11 . The system of claim 8 , wherein the dynamically definable schema is initially set to a null value.
12 . A non-transitory machine-readable storage medium comprising instructions executable by a processor of a computing device for dynamic schema typing, the machine-readable storage medium comprising instructions to:
generate a signature including an object for a schema, wherein the object is initially set to a null value;
receive a value for the object, wherein the value defines a type of data;
determine that the object in the signature is set to the null value; and
generate, dynamically at invocation time, a query using the value for the object in the signature.
13 . The non-transitory machine-readable storage medium of claim 12 further comprising instructions to:
receive a second value defining a second type of the data to be retrieved, wherein the data type schema and the second data type schema are different; and
generating a second query using the second data type schema as a value for the dynamically definable schema.
14 . The non-transitory machine-readable storage medium of claim 12 further comprising instructions to:
retrieve the data from an unstructured data source.
15 . The non-transitory machine-readable storage medium of claim 12 , wherein the signature is created by a function factory.