From 375015e2f75b5a4f61fdf3f6a28c5c6881fd27ab Mon Sep 17 00:00:00 2001 From: dobarx Date: Tue, 20 Feb 2024 10:27:12 +0200 Subject: [PATCH] parser: fix result type for data sources --- cmd/data.go | 2 +- examples/templates/openai/example.fabric | 4 ++-- parser/caller.go | 4 ++-- parser/definitions/config.go | 2 +- parser/evaluation/plugincaller.go | 2 +- test/e2e/data_test.go | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/data.go b/cmd/data.go index 6641cdf5..845c1970 100644 --- a/cmd/data.go +++ b/cmd/data.go @@ -19,7 +19,7 @@ import ( var dataTgtRe = regexp.MustCompile(`(?:document\.([^.]+)\.data\.([^.]+)\.([^.\n]+))|(?:data\.([^.]+)\.([^.]+))`) -func Data(ctx context.Context, blocks *parser.DefinedBlocks, caller *parser.Caller, target string) (result plugin.MapData, diags diagnostics.Diag) { +func Data(ctx context.Context, blocks *parser.DefinedBlocks, caller *parser.Caller, target string) (result plugin.Data, diags diagnostics.Diag) { // docName, pluginName, blockName // target: document..data.. tgt := dataTgtRe.FindStringSubmatch(target) diff --git a/examples/templates/openai/example.fabric b/examples/templates/openai/example.fabric index 203e6ea9..45a3a79e 100644 --- a/examples/templates/openai/example.fabric +++ b/examples/templates/openai/example.fabric @@ -22,7 +22,7 @@ document "example" { absolute_title_size = 2 } content table { - query = ".data.csv.csv_file.result" + query = ".data.csv.csv_file" columns = [ { "header" = "ID" @@ -50,7 +50,7 @@ document "example" { config { api_key = "" } - query = ".data.csv.csv_file.result" + query = ".data.csv.csv_file" model = "gpt-3.5-turbo" prompt = "Decribe each user in a sentence" } diff --git a/parser/caller.go b/parser/caller.go index 3647a185..37034ed8 100644 --- a/parser/caller.go +++ b/parser/caller.go @@ -161,14 +161,14 @@ func (c *Caller) CallContent(ctx context.Context, name string, config evaluation return } -func (c *Caller) CallData(ctx context.Context, name string, config evaluation.Configuration, invocation evaluation.Invocation) (result plugin.MapData, diag diagnostics.Diag) { +func (c *Caller) CallData(ctx context.Context, name string, config evaluation.Configuration, invocation evaluation.Invocation) (result plugin.Data, diag diagnostics.Diag) { var ok bool var res any res, diag = c.callPlugin(ctx, definitions.BlockKindData, name, config, invocation, nil) if diag.HasErrors() { return } - result, ok = res.(plugin.MapData) + result, ok = res.(plugin.Data) if !ok { panic("Incorrect plugin result type") } diff --git a/parser/definitions/config.go b/parser/definitions/config.go index 39456b27..39edbd95 100644 --- a/parser/definitions/config.go +++ b/parser/definitions/config.go @@ -112,4 +112,4 @@ func DefineConfig(block *hclsyntax.Block) (config *Config, diags diagnostics.Dia return } -type ConfigResolver func(pluginKind string, pluginName string) (config *Config) +type ConfigResolver func(pluginKind, pluginName string) (config *Config) diff --git a/parser/evaluation/plugincaller.go b/parser/evaluation/plugincaller.go index 2de5c053..5bd73e08 100644 --- a/parser/evaluation/plugincaller.go +++ b/parser/evaluation/plugincaller.go @@ -8,7 +8,7 @@ import ( ) type DataCaller interface { - CallData(ctx context.Context, name string, config Configuration, invocation Invocation) (result plugin.MapData, diag diagnostics.Diag) + CallData(ctx context.Context, name string, config Configuration, invocation Invocation) (result plugin.Data, diag diagnostics.Diag) } type ContentCaller interface { diff --git a/test/e2e/data_test.go b/test/e2e/data_test.go index a4abdc33..75338309 100644 --- a/test/e2e/data_test.go +++ b/test/e2e/data_test.go @@ -34,7 +34,7 @@ func dataTest(t *testing.T, testName string, files []string, target string, expe eval.Cleanup(nil) }() - var res plugin.MapData + var res plugin.Data diags := eval.ParseFabricFiles(sourceDir) if !diags.HasErrors() { if !diags.Extend(eval.LoadRunner()) {