Datasets not equal but no differences found?

I have to rewrite some stored procedures so I am writing a test to make sure for every input I am getting the same output.

I have something like

from com.inductiveautomation.common.util import DatasetTestUtils

def testSP():
    orig_call = system.db.createSProcCall('orginalSP')
    new_call = system.db.createSProceCall('newSP')
    orig_data = orig_call.getResultSet()
    new_data = new_call.getResultSet()
    comparison = DatasetTestUtils.equals(orig_data, new_data)
    print str(comparison)
    return orig_data, new_data

# another func 
def compareDS(ds1, ds2):
    pyDs1 = set(tuple(row) for row in system.dataset.toPyDataSet(ds1))
    pyDs2 = set(tuple(row) for row in system.dataset.toPyDataSet(ds2))
    print 'in original but not new'
    print pyDs1 - pyDs2
    print 'in new but not original'
    print pyDs2 - pyDs1

orig_data, new_data = testSP()
comapreDS(orig_data, new_data)

Print ds1/ds2 shows the same number of rows and columns. str(comparison) is false but @pturmel forsaw the future before I even finished writing the post so that's explainable.

I copied compareDS from @JordanCClark and both print statements show me an empty set - it seems like it should work.

The basic equality check for objects is "sameness", not content. You'll need to use Paul's module.


Will Paul's module work for 7.9?

Will probably have to write your own checks to determine equality.

1 Like

Oooh, no. Missed that tag.

I suppose you can look at how Paul's module does it and replicate it yourself. Whether in a real module or some jython.

Amazed you called that after I accidentally made the post only halfway through.


By sameness you mean two variables referring to the same object, not sameness in terms of the dataset shape (columns/ rows/ column names).

Edit: Just tested it this seems to be the case.

I guess then my compareDS function will do the heavy lifting of comparing, it seems a very reasonable way to do it.