如何解决如何从用户定义的函数访问值,该函数在 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 举报,一经查实,本站将立刻删除。