Test Canonical Transform from console


#1

Given a string that represent a row from a Canonical file i.e. string = “field1;field2;field3” … is it possible to test the transform for that canonical at console level ? something like CanonicalExmple.process(string)?


#2

You can do something like this (though @garrynigel will not recommend):

var canonicals = [
  CanonicalExmple.make({
    field1: val1,
    . . .
  }),
  CanonicalExmple.make({
    field1: val1,
    . . .
  })
];
CanonicalExmple.process(canonicals); // synchronous call

Now your instances are created and stored, you can fetch them with:

Example.fetch()

I hope that helps.


#3

Thanks Bachir - I’m interested to replicate what the data load does with raw data - providing a string and not building the json manually


#4

I think you’re looking for CanonicalTestRunner:

var testPackage = MetadataStore.current().package("myTenant", true);
var testPath = MetadataPath.make({
  repository: testPackage.repository,
  package: testPackage.package,
  category: MetadataFileCategory.OTHER,
  encodedSubPath: "test/canonical/folder1"
});
var resStatus = CanonicalTestRunner.generateExpectedResult(testPath, "/path/myTenant/test/canonical/folder1/referenceResults");

I don’t think it will work on strings though, just test data that’s been provisioned.

h/t @jinyanliu


partitionKeyIsRequired error when processing a canonical mixing PhysicalMeasurementSeries