Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

Strange behavior from inMemory tables when grouping

(0) ShareShare
ReportReport
Posted on by 1,669

Hi everyone

I just learnt about some strange behaviour from AX that occurs when you group on inMemory tables.

If I say

MyTable t;

select ColA from t group by ColA;
print t.ColB;

then naturally, ColB is null if MyTable is a regular or tempDB table because it isn't part of the field list, nor is it being grouped on which means it's truncated, but strangely, ColB has a value if MyTable is inMemory.
I know these table types are stored differently between the AOS and SQL depending on what type they are, but is this behaviour a bug or a feature?
If it's a feature, what are the rules for what value ColB gets and is there any documentation for it? Does ColB just get the first value for each group of ColA?

Any thoughts appreciated. Tx

  • BrandonSA Profile Picture
    BrandonSA 1,669 on at
    RE: Strange behavior from inMemory tables when grouping

    Thanks Martin for looking into it, it is a very strange error

  • Martin Dráb Profile Picture
    Martin Dráb 230,458 Most Valuable Professional on at
    RE: Strange behavior from inMemory tables when grouping

    All I can say is that I see the same behavior as you. It looks wrong to me and I have no explanation for it.

  • BrandonSA Profile Picture
    BrandonSA 1,669 on at
    RE: Strange behavior from inMemory tables when grouping

    Sure. Thank you Martin

    static client void Job49(Args _args)
    {
       MyTable t;

       void insert(str a, str b)
       {
           t.initValue();
           t.ColA = a;
           t.ColB = b;
           t.insert();
       }

       insert('Alpha', 'One');
       insert('Gamma', 'Two');
       insert('Alpha', 'Three');
       insert('Beta', 'Four');

       while select ColA from t group by ColA
       {
           info(strFmt('%1 %2', t.ColA, t.ColB));
       }
    }

  • Martin Dráb Profile Picture
    Martin Dráb 230,458 Most Valuable Professional on at
    RE: Strange behavior from inMemory tables when grouping

    Interesting. I'm not sure if I can find much about how the kernel handles it, but I'll try. Could you please share your code, so everyone doesn't have to type it again?

  • BrandonSA Profile Picture
    BrandonSA 1,669 on at
    RE: Strange behavior from inMemory tables when grouping

    Hi Martin

    Thank you for the reply. I did have a typo in my post, omitting t when printing ColB - I've updated my post to correct it.

    I just set the scenario up in Ax and ran it. Here is the result: (MyTable is inMemory)

    pastedimage1683759942990v1.png

    Ax Version is Ax 2012 R2 CU7

    PS. Interestingly, I just ran the same job in F&O (10.0.33) and still get the same behavior:

    pastedimage1683761915000v1.png

  • Martin Dráb Profile Picture
    Martin Dráb 230,458 Most Valuable Professional on at
    RE: Strange behavior from inMemory tables when grouping

    I've never seen such a problem with InMemory tables.

    Your code snippet seems to print ColB variable, not t.ColB field. Is your actual code correct? Can you please give us an example that we could run, using a standard temporary table? For example, you could use TmpSearchResult table, if it exists in AX 2012 (I can't be sure because I'm on F&O).

    What value do you see in the field?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans