Source - TabularWriteableSourceBuilder
Source.TabularWriteableSourceBuilderA helper class to build a data
Source, which populates a data Stream with data. Data sources can range from simple clocks to complex database queries or API requests.A corresponding
Template can be created using.toTemplate()
.
Remarks
See
Ingest Structured Data for a related learning module.Type parameters
Name | Type |
---|---|
T | extends DictType |
Inputs | extends Record |
Hierarchy
-
AbstractSourceBuilder
↳
TabularWriteableSourceBuilder
Source
error
▸ error(config
):
TabularWriteableSourceBuilder
Check the source outputs for validity and identify any errors. When the if
predicate returns true
the source will be terminated with an error message and output data will not be produced.
Parameters
Name | Type | Description |
---|---|---|
config | Object | the error message and predicate |
config.if | (value : Variable , inputs : Inputs ) => EastFunction | If true an error will be created |
config.message | string | (value : Variable , inputs : Inputs ) => EastFunction | The message in the case that an error is created |
Returns
TabularWriteableSourceBuilder
a new
SourceBuilderExample
const source = new SourceBuilder("FloatSource")
.input({ name: "max", stream: max_stream })
.writeable(FloatType)
.error({
if: (value, { max }) => Greater(value, max),
message: (value) => StringJoin`The value ${value} exceeds maximum`
})
Inherited from
AbstractSourceBuilder.error
errorEvery
▸ errorEvery(config
):
TabularWriteableSourceBuilder
Add an assertion on every row of the source output to identify errors. For each row when the if
predicate returns true
the source will be terminated with an error message and output data will not be produced.
Parameters
Name | Type | Description |
---|---|---|
config | Object | the error message and predicate |
config.if | (fields : TypeToFields , key : Variable , inputs : Inputs ) => EastFunction | If true an error will be created |
config.message | string | (fields : TypeToFields , key : Variable , inputs : Inputs ) => EastFunction | The message in the case that an error is created |
Returns
TabularWriteableSourceBuilder
a new
SourceBuilderExample
const maximumValue = Stream("MaximumValue", FloatType)
const tableSource = new SourceBuilder("TableSource")
.input({ name: "max", stream: other })
.writeable(DictType(StringType, StructType({ id: IntegerType, value: FloatType, })))
.errorEvery({
if: ({ value }, { max }) => Greater(value, max),
message: ({ id }) => StringJoin`The value for row with id ${id} exceeds maximum`
})
input
▸ input(config
):
TabularWriteableSourceBuilder
<T
, Inputs
& { [K in string]: Variable }>
Add a stream as input to the SourceBuilder
, which can be used in
expressions to configure how the
Type parameters
Name | Type |
---|---|
Name | extends string |
S | extends EastType |
Parameters
Name | Type | Description |
---|---|---|
config | Object | the configuration for the input |
config.name | Name extends "input" | keyof Inputs ? never : Name | the name to give the input Variable |
config.stream | Stream | the input stream (the stream and associated preconditions) |
Returns
TabularWriteableSourceBuilder
<T
, Inputs
& { [K in string]: Variable }>
a new
SourceBuilderExample
const other = Stream("Other", FloatType)
const source = new SourceBuilder("Source")
.input({ name: "other", stream: other })
.clock({ cron: "0 * * * *" })
.toSource()
log
▸ log(config
):
TabularWriteableSourceBuilder
Produce log messages based on the source outputs and inputs. When the if
predicate returns true
source will register a warning with a message, but will proceed to proceed to produce output data.
Parameters
Name | Type | Description |
---|---|---|
config | Object | the log message and optional predicate |
config.if? | (value : Variable , inputs : Inputs ) => EastFunction | If true a log message will be produced (optional) |
config.message | string | (value : Variable , inputs : Inputs ) => EastFunction | The message in the case that a warning is created |
Returns
TabularWriteableSourceBuilder
a new
SourceBuilderExample
const source = new SourceBuilder("FloatSource")
.input({ name: "max", stream: max_stream })
.writeable(FloatType)
.log({
if: (value, { max }) => Greater(value, max),
message: (value) => StringJoin`The value ${value} exceeds maximum`
})
Inherited from
AbstractSourceBuilder.log
logEvery
▸ logEvery(config
):
TabularWriteableSourceBuilder
Produce a long message for every row of the table. For each row when the if
predicate returns true
the source will register a log message and proceed to proceed to produce output data.
Parameters
Name | Type | Description |
---|---|---|
config | Object | the log message and optional predicate |
config.if? | (fields : TypeToFields , key : Variable , inputs : Inputs ) => EastFunction | If true a log message will be produced |
config.message | string | (fields : TypeToFields , key : Variable , inputs : Inputs ) => EastFunction | The message in the case that a warning is create |
Returns
TabularWriteableSourceBuilder
a new
SourceBuilderExample
const maximumValue = Stream("MaximumValue", FloatType)
const tableSource = new SourceBuilder("TableSource")
.input({ name: "max", stream: other })
.writeable(DictType(StringType, StructType({ id: IntegerType, value: FloatType, })))
.logEvery({
if: ({ value }, { max }) => Greater(value, max),
message: ({ id }) => StringJoin`The value for row with id ${id} exceeds maximum`
})
outputStream
▸ outputStream():
Stream
Return the
Stream containing the output of the data source.Returns
Stream
Example
// Create a datastream where a password can be written by end-user at runtime.
const hourly = new SourceBuilder("DatabasePassword")
.writeable(StringType)
.outputStream()
Overrides
AbstractSourceBuilder.outputStream
toTemplate
▸ toTemplate():
Template
Return a
Template fragment containing the Streams and TaskDescriptions built by this builder.Returns
Template
Example
// Create a datastream which is updated to the current time at the beginning of every hour
export default new SourceBuilder("Hourly")
.clock({ cron: "0 * * * *" })
.toTemplate()
Overrides
AbstractSourceBuilder.toTemplate
warn
▸ warn(config
):
TabularWriteableSourceBuilder
Check the source outputs for validity and produce warnings as necessary. When the if
predicate returns true
the source will register a warning with a message, but will proceed to proceed to produce output data.
Parameters
Name | Type | Description |
---|---|---|
config | Object | the warning message and predicate |
config.if | (value : Variable , inputs : Inputs ) => EastFunction | If true a warning will be produced |
config.message | string | (value : Variable , inputs : Inputs ) => EastFunction | The message in the case that a warning is created |
Returns
TabularWriteableSourceBuilder
a new
SourceBuilderExample
const source = new SourceBuilder("FloatSource")
.input({ name: "max", stream: max_stream })
.writeable(FloatType)
.warn({
if: (value, { max }) => Greater(value, max),
message: (value) => StringJoin`The value ${value} exceeds maximum`
})
Inherited from
AbstractSourceBuilder.warn
warnEvery
▸ warnEvery(config
):
TabularWriteableSourceBuilder
Add an warning on every row of the source output to identify errors. For each row when the if
predicate returns true
the source will register a warning with a message, but will proceed to proceed to produce output data.
Parameters
Name | Type | Description |
---|---|---|
config | Object | the warning message and predicate |
config.if | (fields : TypeToFields , key : Variable , inputs : Inputs ) => EastFunction | If true a warning will be produced |
config.message | string | (fields : TypeToFields , key : Variable , inputs : Inputs ) => EastFunction | The message in the case that a warning is create |
Returns
TabularWriteableSourceBuilder
a new
SourceBuilderExample
const maximumValue = Stream("MaximumValue", FloatType)
const tableSource = new SourceBuilder("TableSource")
.input({ name: "max", stream: other })
.writeable(DictType(StringType, StructType({ id: IntegerType, value: FloatType, })))
.warnEvery({
if: ({ value }, { max }) => Greater(value, max),
message: ({ id }) => StringJoin`The value for row with id ${id} exceeds maximum`
})
writeableStream
▸ writeableStream():
Stream
Return the
Stream containing the stream end-users can write to.Returns
Stream
Example
// Create a datastream where a password can be written by end-user at runtime.
const hourly = new SourceBuilder("DatabasePassword")
.writeable(StringType)
.outputStream()