-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
materialize-elasticsearch: materialize singly-typed arrays
With array inference information available in the connector protocol, materializations like Elasticsearch can create appropriately typed "array" index mappings for schematized arrays where there is known to be a single type of item.
- Loading branch information
1 parent
7f596b0
commit e5153ea
Showing
7 changed files
with
173 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
pf "github.com/estuary/flow/go/protocols/flow" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestPropForProjection(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
in *pf.Projection | ||
want property | ||
}{ | ||
{ | ||
name: "array with string items - nullable", | ||
in: &pf.Projection{ | ||
Inference: pf.Inference{ | ||
Types: []string{"array", "null"}, | ||
Array: &pf.Inference_Array{ | ||
ItemTypes: []string{"string", "null"}, | ||
}, | ||
}, | ||
}, | ||
want: property{Type: elasticTypeText}, | ||
}, | ||
{ | ||
name: "array with string items - not nullable", | ||
in: &pf.Projection{ | ||
Inference: pf.Inference{ | ||
Types: []string{"array"}, | ||
Array: &pf.Inference_Array{ | ||
ItemTypes: []string{"string"}, | ||
}, | ||
}, | ||
}, | ||
want: property{Type: elasticTypeText}, | ||
}, | ||
{ | ||
name: "array with object items", | ||
in: &pf.Projection{ | ||
Inference: pf.Inference{ | ||
Types: []string{"array"}, | ||
Array: &pf.Inference_Array{ | ||
ItemTypes: []string{"object"}, | ||
}, | ||
}, | ||
}, | ||
want: property{Type: elasticTypeFlattened, IgnoreAbove: 32766 / 4}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := propForProjection(tt.in, tt.in.Inference.Types, nil) | ||
require.NoError(t, err) | ||
require.Equal(t, tt.want, got) | ||
}) | ||
} | ||
} |
Oops, something went wrong.