Skip to content

Commit

Permalink
parser: fix result type for data sources
Browse files Browse the repository at this point in the history
  • Loading branch information
dobarx committed Feb 20, 2024
1 parent 7ce5063 commit 375015e
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.<doc-name>.data.<plugin-name>.<data-name>
tgt := dataTgtRe.FindStringSubmatch(target)
Expand Down
4 changes: 2 additions & 2 deletions examples/templates/openai/example.fabric
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -50,7 +50,7 @@ document "example" {
config {
api_key = "<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"
}
Expand Down
4 changes: 2 additions & 2 deletions parser/caller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion parser/definitions/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion parser/evaluation/plugincaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit 375015e

Please sign in to comment.