BatchExport TypeA and Import to TypeB

#1

I need to perform an export of typeA from an enviroment and import it as typeB in another env.
The structure and fields of the 2 types are the same … only difference is type name… do we have an API for this?

0 Likes

#2

1- Environment A: export typeA data to S3

var spec = ExportDataSpec.make({
  contentName: 's3://bucket-name/migration/TypeA/data.contentType.gz',
  progressCallbackPeriod: 30,
  contentType: 'text/csv', //or 'application/json'
  contentEncoding: 'gzip',
  csvHeader: 'the name fields of typeA separated by comma'  //jsonInclude for json
});
c3Type(typeA).exportData(spec)

2- Copy files if needed between Environment A and Environment B buckets.
3- Environment B: import data into typeB from S3

var async = false;
c3Type(typeB).importData({
  url: 's3://bucket-name/migration/TypeB/data.contentType.gz',
  createOnly: true,
  directPath: true
}, async);
0 Likes

#3

I’m having this error “wrapped RuntimeException: Expecting result to be Obj” - I had to add also the “carbon” attirbute - do not know its role

var spec = ExportDataSpec.make({
  contentName: 'myBucket/RevenueOpportunityScoreHistory/exportRevenueOpportunityScoreHistory-G4PGPM2TBL-0.json.gz',
  progressCallbackPeriod: 30,
  contentType: 'application/json', //or 'application/json'
  contentEncoding: 'gzip',
  filter:"parent=='100000241'",
  carbon:"RevenueOpportunityScoreHistory"
});

RevenueOpportunityScoreHistory.exportData(spec)```
0 Likes

#4

I remember that you can either use carbon or the jsonInclude/csvHeader fields, but not none of them.

0 Likes

#5

Including the jsonInclude it was able to export

var spec = ExportDataSpec.make({
  contentName: 'mybucket/RevenueOpportunityScoreHistory/exportRevenueOpportunityScoreHistory-G4PGPM2TBL-0.json.gz',
  progressCallbackPeriod: 30,
  contentType: 'application/json', //or 'application/json'
  contentEncoding: 'gzip',
  filter:"parent=='100000241'",
  jsonInclude:"adjustedProbability,anomalyProbability,classifierVersion,dataVersion,estimatedEnergyLoss,expectedEnergyRecovery,inspectionProbability,name,parent,timestamp,value,version,passesFilters"
});

But when Importing thoe the CustomerRevenueOpportunityScoreHistory I have this error instead

Obj should be mixing in the root type: CustomerRevenueOpportunityScoreHistory

This the command executed

CustomerRevenueOpportunityScoreHistory.importData({
  url: 'mybucket/RevenueOpportunityScoreHistory/exportRevenueOpportunityScoreHistory-G4PGPM2TBL-0.json.gz',
  createOnly: false,
  directPath: false
}, async);
0 Likes

#6

Did you have a look at an example of export json?
I’m afraid the type field is included, if so then it will mess the import and you’re trying to important to a different type.

I think in your case it’s better to use CSV.

0 Likes

#7

confirm the type is there and moving to csv fixed that

0 Likes