Class DatabricksMetricViewService
- Inheritance
-
DatabricksMetricViewService
- Inherited Members
- Namespace
- TabularEditor.SemanticBridge.Platforms.Databricks
- Assembly
- SemanticBridge.dll
Databricks MetricView operations and state management service. Manages a single current MetricView instance and provides operations for loading, validation, and conversion to Tabular models.
public class DatabricksMetricViewService
- Extension Methods
Properties
ImportDiagnostics
public ImmutableList<DiagnosticMessage> ImportDiagnostics { get; }
Property Value
| Type | Description |
|---|---|
| ImmutableList<DiagnosticMessage> |
Model
Gets the currently loaded MetricView, or null if no view is loaded. Use Load(string) or Deserialize(string) to load a view.
public View? Model { get; }
Property Value
| Type | Description |
|---|---|
| View |
Methods
Deserialize(string)
Deserializes a Databricks MetricView from a YAML string and sets it as the current view. Deserializing a new view replaces any previously loaded view.
public void Deserialize(string yamlContent)
Parameters
| Type | Name | Description |
|---|---|---|
| string | yamlContent | The YAML string to deserialize. |
Exceptions
- InvalidDataException
Thrown when the YAML is invalid.
ImportToTabular(Model, string, string, out List<DiagnosticMessage>, bool)
Converts the currently loaded Databricks MetricView to a Tabular Model.
public bool ImportToTabular(Model model, string databricksHostName, string databricksHttpPath, out List<DiagnosticMessage> diagnostics, bool failOnValidationErrors = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Model | model | The target TOM model to populate. |
| string | databricksHostName | Databricks host name for connection. |
| string | databricksHttpPath | Databricks HTTP path for connection. |
| List<DiagnosticMessage> | diagnostics | Diagnostic messages from validation and conversion. |
| bool | failOnValidationErrors | If true, abort on validation errors before creating TOM objects. |
Returns
| Type | Description |
|---|---|
| bool | True if conversion succeeded, false if critical errors occurred. |
Exceptions
- InvalidOperationException
Thrown when no MetricView is currently loaded.
ImportToTabularFromFile(string, Model, string, string, out List<DiagnosticMessage>, bool)
Loads a MetricView from a YAML file and converts it to a Tabular Model in one operation.
public bool ImportToTabularFromFile(string yamlPath, Model model, string databricksHostName, string databricksHttpPath, out List<DiagnosticMessage> diagnostics, bool failOnValidationErrors = true)
Parameters
| Type | Name | Description |
|---|---|---|
| string | yamlPath | Full path to the YAML file to load. |
| Model | model | The target TOM model to populate. |
| string | databricksHostName | Databricks host name for connection. |
| string | databricksHttpPath | Databricks HTTP path for connection. |
| List<DiagnosticMessage> | diagnostics | Diagnostic messages from validation and conversion. |
| bool | failOnValidationErrors | If true, abort on validation errors before creating TOM objects. |
Returns
| Type | Description |
|---|---|
| bool | True if conversion succeeded, false if critical errors occurred. |
Load(string)
Loads a Databricks MetricView from a YAML file and sets it as the current view. Loading a new view replaces any previously loaded view.
public void Load(string yamlPath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | yamlPath | Full path to the YAML file on disk. |
Exceptions
- InvalidDataException
Thrown when the YAML is invalid.
- FileNotFoundException
Thrown when the file does not exist.
MakeValidationRuleForDimension(string, string, string, Func<Dimension, bool>)
Creates a validation rule specifically for Dimension objects.
public IMetricViewValidationRule MakeValidationRuleForDimension(string name, string category, string message, Func<Dimension, bool> isInvalid)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Unique name for the validation rule |
| string | category | Category for organizational purposes |
| string | message | Error message returned when the dimension is invalid |
| Func<Dimension, bool> | isInvalid | Predicate function that returns true when the dimension is invalid |
Returns
| Type | Description |
|---|---|
| IMetricViewValidationRule | A validation rule for Dimension objects |
MakeValidationRuleForJoin(string, string, string, Func<Join, bool>)
Creates a validation rule specifically for Join objects.
public IMetricViewValidationRule MakeValidationRuleForJoin(string name, string category, string message, Func<Join, bool> isInvalid)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Unique name for the validation rule |
| string | category | Category for organizational purposes |
| string | message | Error message returned when the join is invalid |
| Func<Join, bool> | isInvalid | Predicate function that returns true when the join is invalid |
Returns
| Type | Description |
|---|---|
| IMetricViewValidationRule | A validation rule for Join objects |
MakeValidationRuleForMeasure(string, string, string, Func<Measure, bool>)
Creates a validation rule for Measure objects.
public IMetricViewValidationRule MakeValidationRuleForMeasure(string name, string category, string message, Func<Measure, bool> isInvalid)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Unique name for the validation rule |
| string | category | Category for organizational purposes |
| string | message | Error message returned when the measure is invalid |
| Func<Measure, bool> | isInvalid | Predicate function that returns true when the measure is invalid |
Returns
| Type | Description |
|---|---|
| IMetricViewValidationRule | A validation rule for Measure objects |
MakeValidationRuleForView(string, string, string, Func<View, bool>)
Creates a validation rule for the root View object.
public IMetricViewValidationRule MakeValidationRuleForView(string name, string category, string message, Func<View, bool> isInvalid)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the rule. |
| string | category | Category for the rule. |
| string | message | Error message to return if validation fails. |
| Func<View, bool> | isInvalid | Predicate function to determine if the view is invalid. |
Returns
| Type | Description |
|---|---|
| IMetricViewValidationRule | A validation rule for use in validation. |
MakeValidationRule<T>(string, string, Func<T, IReadOnlyValidationContext, IEnumerable<DiagnosticMessage>>)
Creates a context-aware validation rule for a specific MetricView object type. The validation function receives both the object and the validation context.
public IMetricViewValidationRule MakeValidationRule<T>(string name, string category, Func<T, IReadOnlyValidationContext, IEnumerable<DiagnosticMessage>> validate) where T : IMetricViewObject
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Unique name for the validation rule |
| string | category | Category for organizational purposes (e.g., "Naming", "Structure") |
| Func<T, IReadOnlyValidationContext, IEnumerable<DiagnosticMessage>> | validate | Validation function that receives the object and context, and returns diagnostic messages |
Returns
| Type | Description |
|---|---|
| IMetricViewValidationRule | A validation rule that can be used with Validate(IEnumerable<IMetricViewValidationRule>) |
Type Parameters
| Name | Description |
|---|---|
| T | Type of MetricView object the rule applies to (View, Join, Dimension, or Measure) |
MakeValidationRule<T>(string, string, string, Func<T, bool>)
Creates a validation rule for a specific type of MetricView object with simple predicate validation.
public IMetricViewValidationRule MakeValidationRule<T>(string name, string category, string message, Func<T, bool> isInvalid) where T : IMetricViewObject
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Unique name for the validation rule |
| string | category | Category for organizational purposes (e.g., "Naming", "Structure") |
| string | message | Error message returned when the object is invalid |
| Func<T, bool> | isInvalid | Predicate function that returns true when the object is invalid |
Returns
| Type | Description |
|---|---|
| IMetricViewValidationRule | A validation rule that can be used with Validate(IEnumerable<IMetricViewValidationRule>) |
Type Parameters
| Name | Description |
|---|---|
| T | Type of MetricView object the rule applies to (View, Join, Dimension, or Measure) |
Save(string)
Saves the currently loaded MetricView to a YAML file.
public void Save(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The path where the YAML file should be saved. |
Exceptions
- InvalidOperationException
Thrown when no MetricView is currently loaded.
- IOException
Thrown when the file cannot be written.
Serialize()
Serializes the currently loaded MetricView to a YAML string.
public string Serialize()
Returns
| Type | Description |
|---|---|
| string | The YAML representation of the current MetricView. |
Exceptions
- InvalidOperationException
Thrown when no MetricView is currently loaded.
Validate()
Validates the currently loaded MetricView using default validation rules.
public IEnumerable<DiagnosticMessage> Validate()
Returns
| Type | Description |
|---|---|
| IEnumerable<DiagnosticMessage> | An enumerable of diagnostic messages from validation. |
Exceptions
- InvalidOperationException
Thrown when no MetricView is currently loaded.
Validate(IEnumerable<IMetricViewValidationRule>)
Validates the currently loaded MetricView using the provided custom validation rules. Default rules are not applied unless explicitly included in the rules parameter.
public IEnumerable<DiagnosticMessage> Validate(IEnumerable<IMetricViewValidationRule> rules)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<IMetricViewValidationRule> | rules | The validation rules to apply. |
Returns
| Type | Description |
|---|---|
| IEnumerable<DiagnosticMessage> | An enumerable of diagnostic messages from validation. |
Exceptions
- InvalidOperationException
Thrown when no MetricView is currently loaded.