Skip to content
ostry202 edited this page Feb 12, 2021 · 6 revisions

We can compare two queries in tool memory (between any two databases)

<cmpSqlResultsTest>
    <compare mode="FETCH" fetchSize="1000" chunk="50" diffTableSize="50" delta="0.00001" fileOutputOn="false">
        <sql datasourceName="SQL_SERVER">
            <![CDATA[
SELECT [AddressID]
      ,[AddressLine1]
      ,[AddressLine2]
      ,[City]
      ,[StateProvinceID]
      ,[PostalCode]
      ,[ModifiedDate]
 FROM [AdventureWorks2008R2].[Person].[Address]
 order by AddressID
         ]]>
        </sql>
        <sql datasourceName="PostgreSQL">
            <![CDATA[
select addressid, addressline1, addressline2, city, stateprovinceid, postalcode, modifieddate
from public.personaddress
order by addressid;
        ]]>
        </sql>
    </compare>
</cmpSqlResultsTest>
  • fetchSize - number of records fetched at once. Default is 100. Records are fetch in incremental way, thanks to this we can compere huge data sets "without out of memory problem" - please remember that comparing huge data set can be time consuming - consider using aggregating function
  • chunk - number of differences after which further comparison is stopped. 0 (or if not set) means never stop -> go to the end of all records. Number of differences visible in test result may be smaller than real one if FETCH comparator stopped his job because of chunk. So if the number of differences is equal to the chunk, it may mean that there are more differences. Default value is 0.
  • diffTableSize - number of differences which will be displayed in logs. Even records from first DB/SQL and odd from the second (so the table will have two times more rows than defined here). Default is 5.
  • delta - when two compared values are floating-point, they will be considered as equal when difference between them is less (or equal) than delta. You can set the same value as the BigDecimal/Java can handle. Default is 0.
  • fileOutputOn - boolean value - if true all results will be saved in CSV files (same name as XML test configuration file but with different prefix and extension). File may be incomplete (if chunk > 0 - see above). In case of FETCH comparator 3 files will be generated: test_name_diff.csv - CSV with differences (all or chunked) test_name_sql1.csv - all (or chunked) data returned by first SQL (from config below) test_name_sql2.csv - all (or chunked) data returned by second SQL (from config below) Default is false.
  • datasourceName - names of connection to database engine defined in cmpSqlResults-config.xml file
  <datasource maxPollSize="6">
            <name>SQL_SERVER</name>
            <driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
			<!--<url>jdbc:sqlserver://${SQL_SERVER}\${SQL_SERVERINSTANCE};databaseName=${SQL_SERVERDBNAME}</url>-->
            <url>jdbc:sqlserver://${SQL_SERVER};databaseName=${SQL_SERVERDBNAME}</url>
            <user>${USERNAME}</user>
            <password>${PASSWORD}</password>
        </datasource>