diff --git a/integration/schema-language-server/language-server/src/main/java/ai/vespa/schemals/schemadocument/resolvers/InheritanceResolver.java b/integration/schema-language-server/language-server/src/main/java/ai/vespa/schemals/schemadocument/resolvers/InheritanceResolver.java index c0df7f3f08f8..073d66423466 100644 --- a/integration/schema-language-server/language-server/src/main/java/ai/vespa/schemals/schemadocument/resolvers/InheritanceResolver.java +++ b/integration/schema-language-server/language-server/src/main/java/ai/vespa/schemals/schemadocument/resolvers/InheritanceResolver.java @@ -155,16 +155,17 @@ private static void resolveRankProfileInheritance(SchemaNode inheritanceNode, Pa if (myRankProfileDefinitionNode == null) return; if (!myRankProfileDefinitionNode.hasSymbol() || myRankProfileDefinitionNode.getSymbol().getStatus() != SymbolStatus.DEFINITION) return; - if (inheritedIdentifier.equals("default")) { - inheritanceNode.setSymbolStatus(SymbolStatus.BUILTIN_REFERENCE); - return; - } - - List parentSymbols = context.schemaIndex().findSymbols(inheritanceNode.getSymbol()); - if (parentSymbols.isEmpty()) { - // Handled in resolve symbol ref + if (parentSymbols.isEmpty() || + // prevents rank-profile default inherits default from causing cyclic inheritance + (inheritedIdentifier.equals("default") && myRankProfileDefinitionNode.getSymbol().getShortIdentifier().equals("default")) + ) { + if (inheritedIdentifier.equals("default")) { + inheritanceNode.setSymbolStatus(SymbolStatus.BUILTIN_REFERENCE); + return; + } + // Otherwise handled in resolve symbol ref return; } diff --git a/integration/schema-language-server/language-server/src/main/java/ai/vespa/schemals/schemadocument/resolvers/RankExpression/BuiltInFunctions.java b/integration/schema-language-server/language-server/src/main/java/ai/vespa/schemals/schemadocument/resolvers/RankExpression/BuiltInFunctions.java index b986499f1a77..21a1290cf642 100644 --- a/integration/schema-language-server/language-server/src/main/java/ai/vespa/schemals/schemadocument/resolvers/RankExpression/BuiltInFunctions.java +++ b/integration/schema-language-server/language-server/src/main/java/ai/vespa/schemals/schemadocument/resolvers/RankExpression/BuiltInFunctions.java @@ -334,7 +334,7 @@ public class BuiltInFunctions { // === ML Model features === put("onnx", new GenericFunction("onnx", new FunctionSignature(new SymbolArgument(SymbolType.ONNX_MODEL, "onnx-model")))); put("onnxModel", new GenericFunction("onnxModel", new FunctionSignature(new SymbolArgument(SymbolType.ONNX_MODEL, "onnx-model")))); - put("lightbgm", new GenericFunction("lightbgm", new FunctionSignature(new StringArgument("\"/path/to/lightbgm-model.json\"")))); + put("lightgbm", new GenericFunction("lightgbm", new FunctionSignature(new StringArgument("\"/path/to/lightgbm-model.json\"")))); put("xgboost", new GenericFunction("xgboost", new FunctionSignature(new StringArgument("\"/path/to/xgboost-model.json\"")))); }}; diff --git a/integration/schema-language-server/language-server/src/test/java/ai/vespa/schemals/SchemaParserTest.java b/integration/schema-language-server/language-server/src/test/java/ai/vespa/schemals/SchemaParserTest.java index c7907cd8ece5..03da9451ced1 100644 --- a/integration/schema-language-server/language-server/src/test/java/ai/vespa/schemals/SchemaParserTest.java +++ b/integration/schema-language-server/language-server/src/test/java/ai/vespa/schemals/SchemaParserTest.java @@ -262,6 +262,7 @@ Stream generateGoodFileTests() { * */ "src/test/sdfiles/single/structinfieldset.sd", "src/test/sdfiles/single/attributeposition.sd", + "src/test/sdfiles/single/defaultdefault.sd", }; return Arrays.stream(filePaths) diff --git a/integration/schema-language-server/language-server/src/test/sdfiles/single/defaultdefault.sd b/integration/schema-language-server/language-server/src/test/sdfiles/single/defaultdefault.sd new file mode 100644 index 000000000000..37cc57d71d82 --- /dev/null +++ b/integration/schema-language-server/language-server/src/test/sdfiles/single/defaultdefault.sd @@ -0,0 +1,32 @@ +# This file tests if overriding/extending the rank-profile default works +schema defaultdefault { + document defaultdefault { + field title type string { + indexing: index | summary + } + + field chunk type string { + indexing: index | summary + } + } + + field embedding type tensor(x[384]) { + indexing: (input title || "") . " " . (input chunk || "") | embed e5 | attribute | index + attribute { + distance-metric: angular + } + } + + rank-profile default inherits default { + function cos_sim() { + expression: cos(distance(field, embedding)) + } + } + + rank-profile custom inherits default { + function foo() { + expression: cos_sim() + } + + } +} diff --git a/integration/schema-language-server/language-server/src/test/sdfiles/single/onnxmodel.sd b/integration/schema-language-server/language-server/src/test/sdfiles/single/onnxmodel.sd index c25c84431b6f..dd54d1fb889a 100644 --- a/integration/schema-language-server/language-server/src/test/sdfiles/single/onnxmodel.sd +++ b/integration/schema-language-server/language-server/src/test/sdfiles/single/onnxmodel.sd @@ -20,7 +20,7 @@ schema onnxmodel { } function func_b() { - expression: sum(lightbgm("/path/to/lightbgm-model.json")) + expression: sum(lightgbm("/path/to/lightbgm-model.json")) } } }