如何从用户定义的函数访问值,该函数在 kusto 中返回表格输出

如何解决如何从用户定义的函数访问值,该函数在 kusto 中返回表格输出

我有以下用户定义函数

let myFunction = ()
{
T
| where id ==12345
|mv-expand details.data
|extend CreateTime=todatetime(details_data.["time"])
|extend Code=tostring(details_data.code)
|summarize arg_max(CreateTime,Code)
};

现在我想从上面的函数获取每列的值,该函数返回 1 行和 2 cloumns 类似的东西 |打印 T().CreateTime |打印T().代码

你能帮我实现上述目标吗。

解决方法

toscalar() 函数将完全满足您的需求:

示例:

public class MainActivity extends AppCompatActivity {

    private final NetworkChangeListener networkChangeListener = new NetworkChangeListener();

    final Fragment fragmentHome = new HomeFragment();
    final Fragment fragmentSaved = new SavedFragment();
    final Fragment fragmentProfile = new ProfileHostFragment();
    final FragmentManager fm = getSupportFragmentManager();
    private Fragment active = fragmentHome;
    private FirebaseAuth mFirebaseAuth;
    private FirebaseUser mFirebaseUser;
    private AnimatedBottomBar bottomBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mFirebaseAuth = FirebaseAuth.getInstance();

        showsplash();

        initBottombar();

        initFragmentContainer();
        


    }


    private void initFragmentContainer() {
        fm.beginTransaction().add(R.id.fragment_container,fragmentProfile,"profile").hide(fragmentProfile).commit();
        fm.beginTransaction().add(R.id.fragment_container,fragmentSaved,"saved").hide(fragmentSaved).commit();
        fm.beginTransaction().add(R.id.fragment_container,fragmentHome,"home").commit();
    }


    private void initBottombar() {

        //Bottombar
        bottomBar = findViewById(R.id.bottomNavigationView);

        //Perform itemselectedlistener
        bottomBar.setOnTabSelectListener(new AnimatedBottomBar.OnTabSelectListener() {
            @Override
            public void onTabReselected(int i,@NotNull AnimatedBottomBar.Tab tab) {
            }

            @Override
            public void onTabSelected(int i,@Nullable AnimatedBottomBar.Tab tab,int i1,@NotNull AnimatedBottomBar.Tab tab1) {
                switch (tab1.getId()) {
                    case R.id.tab_profile:

                        //check if user has a profile
                        checkIfUserIsLoggedIn();

                        break;

                    case R.id.tab_saved:
                        fm.beginTransaction().hide(active).show(fragmentSaved).commit();
                        active = fragmentSaved;
                        break;
                    case R.id.tab_explore:
                        fm.beginTransaction().hide(active).show(fragmentHome).commit();
                        active = fragmentHome;
                        break;

                }

            }
        });
    }


    @Override
    protected void onResume() {
        IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
        registerReceiver(networkChangeListener,filter);

        super.onResume();

    }

    @Override
    protected void onPause() {
        unregisterReceiver(networkChangeListener);
        super.onPause();
    }


    public void showsplash() {

        final Dialog dialog = new Dialog(MainActivity.this,android.R.style.Theme_Black_NoTitleBar_Fullscreen);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.fragment_splash_screen);
        dialog.setCancelable(true);
        dialog.show();

        final Handler handler = new Handler();
        final Runnable runnable = new Runnable() {
            @Override
            public void run() {
                {
                    dialog.dismiss();
                }
            }
        };
        handler.postDelayed(runnable,5000);
    }


    private void checkIfUserIsLoggedIn() {

        if (mFirebaseUser != null) {
            //there is a user logged in,show his profile
            fm.beginTransaction().hide(active).show(fragmentProfile).commit();
            active = fragmentProfile;
        } else {
            //there is no user logged in,ask him if want to logged
            IscriptionRequestDialogFragment iscriptionRequestDialogFragment = new IscriptionRequestDialogFragment();
            iscriptionRequestDialogFragment.show(getSupportFragmentManager(),"dialog");
            //keep home tab selected
            bottomBar.selectTabAt(2,false);
            bottomBar.selectTabAt(0,true);
        }


    }

    @Override
    public boolean onKeyDown(int keyCode,KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
//            Prevent activity from being destroyed on back button pressed

            this.moveTaskToBack(true);

        }
        return false;
    }



}

结果将是:

print_0
0.0437954709718918

请注意,访问特定列中的值是使用 let SomeResult = range n from 1 to 1000 step 1 | extend r = 100 * rand() | summarize min(r),max(r),avg(r); print toscalar(SomeResult | project min_r) 运算符完成的。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?