Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using format in a parameter: casting error #517

Closed
HIrena opened this issue Sep 10, 2019 · 2 comments
Closed

Using format in a parameter: casting error #517

HIrena opened this issue Sep 10, 2019 · 2 comments

Comments

@HIrena
Copy link

HIrena commented Sep 10, 2019

Using a following format of the variable within a parameter fails:

<parameter name="targetDay">
  ~[Date and Time].[Date and Time].[Date and Time].[{@DayPlusTwo:yyyy-MM-dd HH:MM}]
</parameter> 

(in a MDX query)

<parameter name="@targetDay" sql-type="date">~{@DayPlusTwoLocal}</parameter>

(in a SQL query)

Most probably the problem is somewhere around the ~ interpretation: the

<parameter name="@targetDay" sql-type="date">@DayPlusTwoLocal</parameter>

runs correctly. The @DayPlusTwoLocal is defined as:

    <variable name="DayPlusTwoLocal">
      <script>
         DateTime.Now.AddDays(-2).Date
      </script>
    </variable>

The error returned is:

NBi.NUnit.Runtime.TestSuite.The measure 'Physical Flows GB [12.1.GGB]' must be fully available with the expected granularity on EDW:
System.AggregateException : One or more errors occurred.
  ----> System.InvalidCastException : Unable to cast object of type 'NBi.Core.Scalar.Resolver.FormatScalarResolver' to type 'NBi.Core.Scalar.Resolver.IScalarResolver`1[System.Object]'.

with the full stack:


at System.Threading.Tasks.Task.FastWaitAll(Task[] tasks)
at System.Threading.Tasks.Parallel.Invoke(ParallelOptions parallelOptions, Action[] actions)
at NBi.NUnit.ResultSetComparison.LookupReverseExistsConstraint.ProcessParallel(IResultSetService actual) in D:\a\1\s\NBi.NUnit\ResultSetComparison\LookupReverseExistsConstraint.cs:line 31
at NBi.NUnit.ResultSetComparison.LookupExistsConstraint.Matches(Object actual) in D:\a\1\s\NBi.NUnit\ResultSetComparison\LookupExistsConstraint.cs:line 65
at NBi.NUnit.Runtime.TestSuite.AssertTestCase(Object systemUnderTest, Constraint constraint, String stackTrace) in D:\a\1\s\NBi.NUnit.Runtime\TestSuite.cs:line 236
at NBi.NUnit.Runtime.TestSuite.ExecuteTestCases(TestXml test, String testName, IDictionary`2 localVariables) in D:\a\1\s\NBi.NUnit.Runtime\TestSuite.cs:line 128
--InvalidCastException
at NBi.Core.Scalar.Resolver.ScalarResolverFactory.Instantiate[T](IScalarResolverArgs args) in D:\a\1\s\NBi.Core\Scalar\Resolver\ScalarResolverFactory.cs:line 39
at NBi.NUnit.Builder.Helper.QueryResolverArgsBuilder.<BuildParameters>d__17.MoveNext() in D:\a\1\s\NBi.NUnit\Builder\Helper\QueryResolverArgsBuilder.cs:line 171
at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
at NBi.Core.Query.Command.DbCommandFactory.Instantiate(IDbConnection connection, IQuery query, ITemplateEngine engine) in D:\a\1\s\NBi.Core\Query\Command\DbCommandFactory.cs:line 38
at NBi.Core.Query.Command.DbCommandFactory.Instantiate(IClient client, IQuery query, ITemplateEngine engine) in D:\a\1\s\NBi.Core\Query\Command\DbCommandFactory.cs:line 26
at NBi.Core.Query.Command.CommandProvider.Instantiate(IClient session, IQuery query) in D:\a\1\s\NBi.Core\Query\Command\CommandProvider.cs:line 52
at NBi.Core.Query.EngineFactory`1.Instantiate(IQuery query) in D:\a\1\s\NBi.Core\Query\EngineFactory.cs:line 49
at NBi.Core.ResultSet.Resolver.QueryResultSetResolver.Load(IQuery query) in D:\a\1\s\NBi.Core\ResultSet\Resolver\QueryResultSetResolver.cs:line 44
at NBi.Core.ResultSet.Resolver.QueryResultSetResolver.Execute() in D:\a\1\s\NBi.Core\ResultSet\Resolver\QueryResultSetResolver.cs:line 29
at NBi.Core.ResultSet.ResultSetService.Execute() in D:\a\1\s\NBi.Core\ResultSet\ResultSetService.cs:line 26
at NBi.NUnit.ResultSetComparison.LookupReverseExistsConstraint.<>c__DisplayClass2_0.<ProcessParallel>b__1() in D:\a\1\s\NBi.NUnit\ResultSetComparison\LookupReverseExistsConstraint.cs:line 33
at System.Threading.Tasks.Task.Execute()

Let me know if more information should be provided, please!

@Seddryck Seddryck added the bug label Sep 10, 2019
@Seddryck Seddryck added this to the v1.21 milestone Sep 10, 2019
@Seddryck Seddryck changed the title Using variable in a parameter: casting error Using format in a parameter: casting error Sep 10, 2019
@Seddryck
Copy link
Owner

Hi,

A fix is available in 1.21.0-beta0341 or at https://ci.appveyor.com/project/Seddryck/nbi/builds/27317396/artifacts

@Seddryck
Copy link
Owner

Note for myself ... avoid usage of IScalarResolver<object> and prefer IScalarResolver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants